diff --git a/GNUmakefile b/GNUmakefile index 8a1ea96364..dbea3a5268 100644 --- a/GNUmakefile +++ b/GNUmakefile @@ -1,127 +1,129 @@ # # Copyright (C) 2008 Andrew Beekhof # # This program is free software; you can redistribute it and/or # modify it under the terms of the GNU General Public License # as published by the Free Software Foundation; either version 2 # of the License, or (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program; if not, write to the Free Software # Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. # -include Makefile PACKAGE ?= pacemaker # Force 'make dist' to be consistent with 'make export' #distdir = $(PACKAGE)-$(VERSION) distdir = $(PACKAGE) TARFILE = $(distdir).tar.bz2 DIST_ARCHIVES = $(TARFILE) LAST_RELEASE = Pacemaker-1.0.7 STABLE_SERIES = stable-1.0 RPM_ROOT = $(shell pwd) RPM_OPTS = --define "_sourcedir $(RPM_ROOT)" \ --define "_specdir $(RPM_ROOT)" \ --define "_srcrpmdir $(RPM_ROOT)" \ # Default to fedora compliant spec files # SLES: /etc/SuSE-release # openSUSE: /etc/SuSE-release # RHEL: /etc/redhat-release # Fedora: /etc/fedora-release, /etc/redhat-release, /etc/system-release getdistro = $(shell test -e /etc/SuSE-release || echo fedora; test -e /etc/SuSE-release && echo suse) DISTRO ?= $(call getdistro) export: rm -f $(TARFILE) hg archive -t tbz2 $(TARFILE) echo `date`: Rebuilt $(TARFILE) pacemaker-fedora.spec: pacemaker.spec cp $(PACKAGE).spec $(PACKAGE)-$(DISTRO).spec @echo Rebuilt $@ pacemaker-suse.spec: pacemaker.spec cp $(PACKAGE).spec $@ sed -i.sed s:%{_docdir}/%{name}:%{_docdir}/%{name}-%{version}:g $@ sed -i.sed s:corosynclib:libcorosync:g $@ sed -i.sed s:pacemaker-libs:libpacemaker3:g $@ sed -i.sed s:heartbeat-libs:heartbeat:g $@ sed -i.sed s:cluster-glue-libs:libglue:g $@ sed -i.sed s:libselinux-devel::g $@ sed -i.sed s:lm_sensors-devel::g $@ sed -i.sed s:Development/Libraries:Development/Libraries/C\ and\ C++:g $@ sed -i.sed s:System\ Environment/Daemons:Productivity/Clustering/HA:g $@ sed -i.sed s:lm_sensors-devel::g $@ sed -i.sed s:bzip2-devel:libbz2-devel:g $@ @echo Rebuilt $@ srpm: export $(PACKAGE)-$(DISTRO).spec rm -f *.src.rpm rpmbuild -bs --define "dist .$(DISTRO)" $(RPM_OPTS) $(PACKAGE)-$(DISTRO).spec rpm: srpm @echo To create custom builds, edit the flags and options in $(PACKAGE)-$(DISTRO).spec first rpmbuild --rebuild $(RPM_ROOT)/*.src.rpm mock-nodeps: -rm -rf $(RPM_ROOT)/mock mock --root=fedora-12-x86_64 --resultdir=$(RPM_ROOT)/mock --rebuild $(RPM_ROOT)/*.src.rpm mock: srpm mock-nodeps scratch: hg commit -m "DO-NOT-PUSH" make srpm hg rollback make mock-nodeps deb: echo To make create custom builds, edit the configure flags in debian/rules first dpkg-buildpackage -rfakeroot -us -uc global: clean-generic gtags -q global-html: global htags -sanhIT global-www: global-html rsync -avzxlSD --progress HTML/ root@clusterlabs.org:/var/lib/global/pacemaker changes: @printf "$(PACKAGE) ($(VERSION)-1) stable; urgency=medium\n" @printf " * Update source tarball to revision: `hg id`\n" @printf " * Statistics:\n" @printf " Changesets: `hg log -M --template "{desc|firstline|strip}\n" -r $(LAST_RELEASE):tip | wc -l`\n" @printf " Diff: " @hg diff -r $(LAST_RELEASE):tip | diffstat | tail -n 1 @printf "\n * Testing Notes:\n" @printf "\n + Test hardware:\n" @printf "\n + All testing was performed with STONITH enabled\n" @printf "\n + Pending bugs encountered during testing:\n" @printf "\n * Changes since $(LAST_RELEASE)\n" @hg log -M --template " + {desc|firstline|strip}\n" -r $(LAST_RELEASE):tip | grep -v -e Dev: -e Low: | sort -uf @printf "\n -- Andrew Beekhof `date +"%a, %d %b %Y %T %z"`\n" features: @printf "$(PACKAGE) ($(VERSION)-1) unstable; urgency=medium\n" @printf " * Update source tarball to revision: `hg id`\n" @printf " * Statistics:\n" @printf " Changesets: `hg out -M --template "{desc|firstline|strip}\n" ../$(STABLE_SERIES) | wc -l`\n" @printf " Diff: " @hg out -M -p ../$(STABLE_SERIES) | diffstat | tail -n 1 @printf "\n * Changes added since $(STABLE_SERIES)\n" @hg out -M --template " + {desc|firstline|strip}\n" ../$(STABLE_SERIES) | grep -v -e Dev: -e Low: | sort -uf @printf "\n -- Andrew Beekhof `date +"%a, %d %b %Y %T %z"`\n" +rel-tags: tags + find . -name TAGS -exec sed -i.sed 's:\(.*\)/\(.*\)/TAGS:\2/TAGS:g' \{\} \; diff --git a/Makefile.am b/Makefile.am index 46a2d466f4..93d6a81f26 100644 --- a/Makefile.am +++ b/Makefile.am @@ -1,51 +1,51 @@ # # Pacemaker code # # Copyright (C) 2004 Andrew Beekhof # # This program is free software; you can redistribute it and/or # modify it under the terms of the GNU General Public License # as published by the Free Software Foundation; either version 2 # of the License, or (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program; if not, write to the Free Software # Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. # EXTRA_DIST = autogen.sh ConfigureMe README.in libltdl.tar MAINTAINERCLEANFILES = Makefile.in aclocal.m4 configure DRF/config-h.in \ DRF/stamp-h.in libtool.m4 ltdl.m4 libltdl.tar -SUBDIRS = debian $(LIBLTDL_DIR) replace include lib pengine cib crmd fencing tools xml cts extra doc +SUBDIRS = debian $(LIBLTDL_DIR) replace include lib pengine cib crmd fencing tools shell xml cts extra doc doc_DATA = AUTHORS COPYING COPYING.LIB AUTOMAKE_OPTIONS = foreign ##ACLOCAL = aclocal -I $(auxdir) install-exec-local: $(INSTALL) -d $(DESTDIR)/$(LCRSODIR) $(INSTALL) -d -m 750 $(DESTDIR)/$(CRM_CONFIG_DIR) $(INSTALL) -d -m 750 $(DESTDIR)/$(CRM_STATE_DIR) -chown $(CRM_DAEMON_USER):$(CRM_DAEMON_GROUP) $(DESTDIR)/$(CRM_CONFIG_DIR) -chown $(CRM_DAEMON_USER):$(CRM_DAEMON_GROUP) $(DESTDIR)/$(CRM_STATE_DIR) if BUILD_AIS_SUPPORT rm -f $(DESTDIR)$(LCRSODIR)/pacemaker.lcrso $(DESTDIR)$(LCRSODIR)/service_crm.so cp $(DESTDIR)$(libdir)/service_crm.so $(DESTDIR)$(LCRSODIR)/pacemaker.lcrso endif # Use chown because the user/group may not exist dist-clean-local: rm -f autoconf automake autoheader $(TARFILE) maintainer-clean-local: rm -f libltdl.tar .PHONY: rpm pkg handy handy-copy diff --git a/cib/callbacks.c b/cib/callbacks.c index 4f388e9398..b12a33a691 100644 --- a/cib/callbacks.c +++ b/cib/callbacks.c @@ -1,1302 +1,1299 @@ /* * Copyright (C) 2004 Andrew Beekhof * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public * License as published by the Free Software Foundation; either * version 2.1 of the License, or (at your option) any later version. * * This software is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * General Public License for more details. * * You should have received a copy of the GNU General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include "common.h" extern GMainLoop* mainloop; extern gboolean cib_shutdown_flag; extern gboolean stand_alone; extern const char* cib_root; #if SUPPORT_HEARTBEAT extern ll_cluster_t *hb_conn; #endif extern void cib_ha_connection_destroy(gpointer user_data); extern enum cib_errors cib_update_counter( xmlNode *xml_obj, const char *field, gboolean reset); extern void GHFunc_count_peers( gpointer key, gpointer value, gpointer user_data); void initiate_exit(void); void terminate_cib(const char *caller); gint cib_GCompareFunc(gconstpointer a, gconstpointer b); gboolean can_write(int flags); void send_cib_replace(const xmlNode *sync_request, const char *host); void cib_process_request( xmlNode *request, gboolean privileged, gboolean force_synchronous, gboolean from_peer, cib_client_t *cib_client); void cib_common_callback_worker(xmlNode *op_request, cib_client_t *cib_client, gboolean force_synchronous, gboolean privileged); extern GHashTable *client_list; int next_client_id = 0; extern const char *cib_our_uname; extern unsigned long cib_num_ops, cib_num_local, cib_num_updates, cib_num_fail; extern unsigned long cib_bad_connects, cib_num_timeouts; extern longclock_t cib_call_time; extern enum cib_errors cib_status; int send_via_callback_channel(xmlNode *msg, const char *token); enum cib_errors cib_process_command( xmlNode *request, xmlNode **reply, xmlNode **cib_diff, gboolean privileged); gboolean cib_common_callback(IPC_Channel *channel, cib_client_t *cib_client, gboolean force_synchronous, gboolean privileged); gboolean cib_process_disconnect(IPC_Channel *channel, cib_client_t *cib_client); int num_clients = 0; static void cib_ipc_connection_destroy(gpointer user_data) { cib_client_t *cib_client = user_data; /* cib_process_disconnect */ if(cib_client == NULL) { crm_debug_4("Destroying %p", user_data); return; } if(cib_client->source != NULL) { crm_debug_4("Deleting %s (%p) from mainloop", cib_client->name, cib_client->source); G_main_del_IPC_Channel(cib_client->source); cib_client->source = NULL; } crm_debug_3("Destroying %s (%p)", cib_client->name, user_data); num_clients--; crm_debug_2("Num unfree'd clients: %d", num_clients); crm_free(cib_client->name); crm_free(cib_client->callback_id); crm_free(cib_client->id); crm_free(cib_client); crm_debug_4("Freed the cib client"); return; } gboolean cib_client_connect(IPC_Channel *channel, gpointer user_data) { cl_uuid_t client_id; xmlNode *reg_msg = NULL; cib_client_t *new_client = NULL; char uuid_str[UU_UNPARSE_SIZEOF]; const char *channel_name = user_data; gboolean (*callback)(IPC_Channel *channel, gpointer user_data); crm_debug_3("Connecting channel"); if (channel == NULL) { crm_err("Channel was NULL"); cib_bad_connects++; return FALSE; } else if (channel->ch_status != IPC_CONNECT) { crm_err("Channel was disconnected"); cib_bad_connects++; return FALSE; } else if(channel_name == NULL) { crm_err("user_data must contain channel name"); cib_bad_connects++; return FALSE; } else if(cib_shutdown_flag) { crm_info("Ignoring new client [%d] during shutdown", channel->farside_pid); return FALSE; } callback = cib_ro_callback; if(safe_str_eq(channel_name, cib_channel_rw)) { callback = cib_rw_callback; } crm_malloc0(new_client, sizeof(cib_client_t)); num_clients++; new_client->channel = channel; new_client->channel_name = channel_name; crm_debug_3("Created channel %p for channel %s", new_client, new_client->channel_name); channel->ops->set_recv_qlen(channel, 1024); channel->ops->set_send_qlen(channel, 1024); new_client->source = G_main_add_IPC_Channel( G_PRIORITY_DEFAULT, channel, FALSE, callback, new_client, cib_ipc_connection_destroy); crm_debug_3("Channel %s connected for client %s", new_client->channel_name, new_client->id); cl_uuid_generate(&client_id); cl_uuid_unparse(&client_id, uuid_str); CRM_CHECK(new_client->id == NULL, crm_free(new_client->id)); new_client->id = crm_strdup(uuid_str); /* make sure we can find ourselves later for sync calls * redirected to the master instance */ g_hash_table_insert(client_list, new_client->id, new_client); reg_msg = create_xml_node(NULL, "callback"); crm_xml_add(reg_msg, F_CIB_OPERATION, CRM_OP_REGISTER); crm_xml_add(reg_msg, F_CIB_CLIENTID, new_client->id); send_ipc_message(channel, reg_msg); free_xml(reg_msg); return TRUE; } gboolean cib_rw_callback(IPC_Channel *channel, gpointer user_data) { gboolean result = FALSE; result = cib_common_callback(channel, user_data, FALSE, TRUE); return result; } gboolean cib_ro_callback(IPC_Channel *channel, gpointer user_data) { gboolean result = FALSE; result = cib_common_callback(channel, user_data, FALSE, FALSE); return result; } void cib_common_callback_worker(xmlNode *op_request, cib_client_t *cib_client, gboolean force_synchronous, gboolean privileged) { longclock_t call_stop = 0; longclock_t call_start = 0; const char *op = crm_element_value(op_request, F_CIB_OPERATION); if(crm_str_eq(op, CRM_OP_REGISTER, TRUE)) { return; } else if(crm_str_eq(op, T_CIB_NOTIFY, TRUE)) { /* Update the notify filters for this client */ int on_off = 0; const char *type = crm_element_value(op_request, F_CIB_NOTIFY_TYPE);; crm_element_value_int(op_request, F_CIB_NOTIFY_ACTIVATE, &on_off); crm_debug("Setting %s callbacks for %s (%s): %s", type, cib_client->name, cib_client->id, on_off?"on":"off"); if(safe_str_eq(type, T_CIB_POST_NOTIFY)) { cib_client->post_notify = on_off; } else if(safe_str_eq(type, T_CIB_PRE_NOTIFY)) { cib_client->pre_notify = on_off; } else if(safe_str_eq(type, T_CIB_UPDATE_CONFIRM)) { cib_client->confirmations = on_off; } else if(safe_str_eq(type, T_CIB_DIFF_NOTIFY)) { cib_client->diffs = on_off; } else if(safe_str_eq(type, T_CIB_REPLACE_NOTIFY)) { cib_client->replace = on_off; } return; } cib_client->num_calls++; call_start = time_longclock(); cib_process_request( op_request, force_synchronous, privileged, FALSE, cib_client); call_stop = time_longclock(); cib_call_time += (call_stop - call_start); } gboolean cib_common_callback(IPC_Channel *channel, cib_client_t *cib_client, gboolean force_synchronous, gboolean privileged) { int lpc = 0; const char *value = NULL; xmlNode *op_request = NULL; gboolean keep_channel = TRUE; CRM_CHECK(cib_client != NULL, crm_err("Invalid client"); return FALSE); CRM_CHECK(cib_client->id != NULL, crm_err("Invalid client: %p", cib_client); return FALSE); /* * Do enough work to make entering worthwhile * But don't allow a single client to monopolize the CIB */ while(lpc < 5 && IPC_ISRCONN(channel) && channel->ops->is_message_pending(channel)) { lpc++; op_request = xmlfromIPC(channel, MAX_IPC_DELAY); if (op_request == NULL) { break; } if(cib_client->name == NULL) { value = crm_element_value(op_request, F_CIB_CLIENTNAME); if(value == NULL) { cib_client->name = crm_itoa(channel->farside_pid); } else { cib_client->name = crm_strdup(value); } } crm_xml_add(op_request, F_CIB_CLIENTID, cib_client->id); crm_xml_add(op_request, F_CIB_CLIENTNAME, cib_client->name); /* crm_log_xml(LOG_MSG, "Client[inbound]", op_request); */ if(cib_client->callback_id == NULL) { value = crm_element_value(op_request, F_CIB_CALLBACK_TOKEN); if(value != NULL) { cib_client->callback_id = crm_strdup(value); } else { cib_client->callback_id = crm_strdup(cib_client->id); } } cib_common_callback_worker( op_request, cib_client, force_synchronous, privileged); free_xml(op_request); } if(channel->ch_status != IPC_CONNECT) { crm_debug_2("Client disconnected"); keep_channel = cib_process_disconnect(channel, cib_client); } return keep_channel; } static void do_local_notify(xmlNode *notify_src, const char *client_id, gboolean sync_reply, gboolean from_peer) { /* send callback to originating child */ cib_client_t *client_obj = NULL; enum cib_errors local_rc = cib_ok; crm_debug_2("Performing notification"); if(client_id != NULL) { client_obj = g_hash_table_lookup(client_list, client_id); } else { crm_debug_2("No client to sent the response to." " F_CIB_CLIENTID not set."); } crm_debug_3("Sending callback to request originator"); if(client_obj == NULL) { local_rc = cib_reply_failed; } else { const char *client_id = client_obj->callback_id; crm_debug_2("Sending %ssync response to %s %s", sync_reply?"":"an a-", client_obj->name, from_peer?"(originator of delegated request)":""); if(sync_reply) { client_id = client_obj->id; } local_rc = send_via_callback_channel(notify_src, client_id); } if(local_rc != cib_ok && client_obj != NULL) { crm_warn("%sSync reply to %s failed: %s", sync_reply?"":"A-", client_obj?client_obj->name:"", cib_error2string(local_rc)); } } static void parse_local_options( cib_client_t *cib_client, int call_type, int call_options, const char *host, const char *op, gboolean *local_notify, gboolean *needs_reply, gboolean *process, gboolean *needs_forward) { if(cib_op_modifies(call_type) && !(call_options & cib_inhibit_bcast)) { /* we need to send an update anyway */ *needs_reply = TRUE; } else { *needs_reply = FALSE; } if(host == NULL && (call_options & cib_scope_local)) { crm_debug_2("Processing locally scoped %s op from %s", op, cib_client->name); *local_notify = TRUE; } else if(host == NULL && cib_is_master) { crm_debug_2("Processing master %s op locally from %s", op, cib_client->name); *local_notify = TRUE; } else if(safe_str_eq(host, cib_our_uname)) { crm_debug_2("Processing locally addressed %s op from %s", op, cib_client->name); *local_notify = TRUE; } else if(stand_alone) { *needs_forward = FALSE; *local_notify = TRUE; *process = TRUE; } else { crm_debug_2("%s op from %s needs to be forwarded to %s", op, cib_client->name, host?host:"the master instance"); *needs_forward = TRUE; *process = FALSE; } } static gboolean parse_peer_options( int call_type, xmlNode *request, gboolean *local_notify, gboolean *needs_reply, gboolean *process, gboolean *needs_forward) { const char *op = crm_element_value(request, F_CIB_OPERATION); const char *originator = crm_element_value(request, F_ORIG); const char *host = crm_element_value(request, F_CIB_HOST); const char *reply_to = crm_element_value(request, F_CIB_ISREPLY); const char *update = crm_element_value(request, F_CIB_GLOBAL_UPDATE); const char *delegated = crm_element_value(request, F_CIB_DELEGATED); if(safe_str_eq(op, "cib_shutdown_req")) { if(reply_to != NULL) { crm_debug("Processing %s from %s", op, host); *needs_reply = FALSE; } else { crm_debug("Processing %s reply from %s", op, host); } return TRUE; } else if(crm_is_true(update) && safe_str_eq(reply_to, cib_our_uname)) { crm_debug_2("Processing global/peer update from %s" " that originated from us", originator); *needs_reply = FALSE; if(crm_element_value(request, F_CIB_CLIENTID) != NULL) { *local_notify = TRUE; } return TRUE; } else if(crm_is_true(update)) { crm_debug_2("Processing global/peer update from %s", originator); *needs_reply = FALSE; return TRUE; } else if(host != NULL && safe_str_eq(host, cib_our_uname)) { crm_debug_2("Processing request sent to us from %s", originator); return TRUE; } else if(delegated != NULL && cib_is_master == TRUE) { crm_debug_2("Processing request sent to master instance from %s", originator); return TRUE; } else if(reply_to != NULL && safe_str_eq(reply_to, cib_our_uname)) { crm_debug_2("Forward reply sent from %s to local clients", originator); *process = FALSE; *needs_reply = FALSE; *local_notify = TRUE; return TRUE; } else if(delegated != NULL) { crm_debug_2("Ignoring msg for master instance"); } else if(host != NULL) { /* this is for a specific instance and we're not it */ crm_debug_2("Ignoring msg for instance on %s", crm_str(host)); } else if(reply_to == NULL && cib_is_master == FALSE) { /* this is for the master instance and we're not it */ crm_debug_2("Ignoring reply to %s", crm_str(reply_to)); } else { crm_err("Nothing for us to do?"); crm_log_xml(LOG_ERR, "Peer[inbound]", request); } return FALSE; } static void forward_request(xmlNode *request, cib_client_t *cib_client, int call_options) { xmlNode *forward_msg = NULL; const char *op = crm_element_value(request, F_CIB_OPERATION); const char *host = crm_element_value(request, F_CIB_HOST); forward_msg = cib_msg_copy(request, TRUE); crm_xml_add(forward_msg, F_CIB_DELEGATED, cib_our_uname); if(host != NULL) { crm_debug_2("Forwarding %s op to %s", op, host); send_cluster_message(host, crm_msg_cib, forward_msg, FALSE); } else { crm_debug_2("Forwarding %s op to master instance", op); send_cluster_message(NULL, crm_msg_cib, forward_msg, FALSE); } if(call_options & cib_discard_reply) { crm_debug_2("Client not interested in reply"); } free_xml(forward_msg); } static void send_peer_reply( xmlNode *msg, xmlNode *result_diff, const char *originator, gboolean broadcast) { xmlNode *reply_copy = NULL; CRM_ASSERT(msg != NULL); reply_copy = cib_msg_copy(msg, TRUE); if(broadcast) { /* this (successful) call modified the CIB _and_ the * change needs to be broadcast... * send via HA to other nodes */ int diff_add_updates = 0; int diff_add_epoch = 0; int diff_add_admin_epoch = 0; int diff_del_updates = 0; int diff_del_epoch = 0; int diff_del_admin_epoch = 0; char *digest = NULL; cib_diff_version_details( result_diff, &diff_add_admin_epoch, &diff_add_epoch, &diff_add_updates, &diff_del_admin_epoch, &diff_del_epoch, &diff_del_updates); crm_debug_2("Sending update diff %d.%d.%d -> %d.%d.%d", diff_del_admin_epoch,diff_del_epoch,diff_del_updates, diff_add_admin_epoch,diff_add_epoch,diff_add_updates); crm_xml_add(reply_copy, F_CIB_ISREPLY, originator); crm_xml_add(reply_copy, F_CIB_GLOBAL_UPDATE, XML_BOOLEAN_TRUE); crm_xml_add(reply_copy, F_CIB_OPERATION, CIB_OP_APPLY_DIFF); digest = calculate_xml_digest(the_cib, FALSE, TRUE); crm_xml_add(result_diff, XML_ATTR_DIGEST, digest); /* crm_log_xml_debug(the_cib, digest); */ crm_free(digest); add_message_xml(reply_copy, F_CIB_UPDATE_DIFF, result_diff); crm_log_xml(LOG_DEBUG_3, "copy", reply_copy); send_cluster_message(NULL, crm_msg_cib, reply_copy, TRUE); } else if(originator != NULL) { /* send reply via HA to originating node */ crm_debug_2("Sending request result to originator only"); crm_xml_add(reply_copy, F_CIB_ISREPLY, originator); send_cluster_message(originator, crm_msg_cib, reply_copy, FALSE); } free_xml(reply_copy); } void cib_process_request( xmlNode *request, gboolean force_synchronous, gboolean privileged, gboolean from_peer, cib_client_t *cib_client) { int call_type = 0; int call_options = 0; gboolean process = TRUE; gboolean is_update = TRUE; gboolean needs_reply = TRUE; gboolean local_notify = FALSE; gboolean needs_forward = FALSE; gboolean global_update = crm_is_true(crm_element_value(request, F_CIB_GLOBAL_UPDATE)); xmlNode *op_reply = NULL; xmlNode *result_diff = NULL; enum cib_errors rc = cib_ok; const char *op = crm_element_value(request, F_CIB_OPERATION); const char *originator = crm_element_value(request, F_ORIG); const char *host = crm_element_value(request, F_CIB_HOST); crm_debug_4("%s Processing msg %s", cib_our_uname, crm_element_value(request, F_SEQ)); cib_num_ops++; if(cib_num_ops == 0) { cib_num_fail = 0; cib_num_local = 0; cib_num_updates = 0; crm_info("Stats wrapped around"); } if(host != NULL && strlen(host) == 0) { host = NULL; } crm_element_value_int(request, F_CIB_CALLOPTS, &call_options); if(force_synchronous) { call_options |= cib_sync_call; } crm_debug_2("Processing %s message (%s) for %s...", from_peer?"peer":"local", from_peer?originator:cib_our_uname, host?host:"master"); rc = cib_get_operation_id(op, &call_type); if(rc != cib_ok) { /* TODO: construct error reply? */ crm_err("Pre-processing of command failed: %s", cib_error2string(rc)); return; } is_update = cib_op_modifies(call_type); if(is_update) { cib_num_updates++; } if(from_peer == FALSE) { parse_local_options(cib_client, call_type, call_options, host, op, &local_notify, &needs_reply, &process, &needs_forward); } else if(parse_peer_options(call_type, request, &local_notify, &needs_reply, &process, &needs_forward) == FALSE) { return; } crm_debug_3("Finished determining processing actions"); if(call_options & cib_discard_reply) { needs_reply = is_update; local_notify = FALSE; } if(needs_forward) { forward_request(request, cib_client, call_options); return; } if(cib_status != cib_ok) { rc = cib_status; crm_err("Operation ignored, cluster configuration is invalid." " Please repair and restart: %s", cib_error2string(cib_status)); op_reply = cib_construct_reply(request, the_cib, cib_status); } else if(process) { int level = LOG_INFO; const char *section = crm_element_value(request, F_CIB_SECTION); cib_num_local++; rc = cib_process_command( request, &op_reply, &result_diff, privileged); if(global_update) { switch(rc) { case cib_ok: case cib_old_data: case cib_diff_resync: case cib_diff_failed: level = LOG_DEBUG_2; break; default: level = LOG_ERR; } } else if(safe_str_eq(op, CIB_OP_QUERY)) { level = LOG_DEBUG_2; } else if(rc != cib_ok) { cib_num_fail++; level = LOG_WARNING; - } else if(safe_str_eq(op, CIB_OP_QUERY)) { - level = LOG_DEBUG_2; - } else if(safe_str_eq(op, CIB_OP_SLAVE)) { level = LOG_DEBUG_2; } else if(safe_str_eq(section, XML_CIB_TAG_STATUS)) { level = LOG_DEBUG_2; } if(crm_log_level >= level) { /* Avoid all the xml lookups if we're not going to print the results */ do_crm_log(level, "Operation complete: op %s for section %s (origin=%s/%s/%s, version=%s.%s.%s): %s (rc=%d)", op, section?section:"'all'", originator?originator:"local", crm_element_value(request, F_CIB_CLIENTNAME), crm_element_value(request, F_CIB_CALLID), the_cib?crm_element_value(the_cib, XML_ATTR_GENERATION_ADMIN):"0", the_cib?crm_element_value(the_cib, XML_ATTR_GENERATION):"0", the_cib?crm_element_value(the_cib, XML_ATTR_NUMUPDATES):"0", cib_error2string(rc), rc); } if(op_reply == NULL && (needs_reply || local_notify)) { crm_err("Unexpected NULL reply to message"); crm_log_xml(LOG_ERR, "null reply", request); needs_reply = FALSE; local_notify = FALSE; } } crm_debug_3("processing response cases"); if(local_notify) { const char *client_id = crm_element_value(request, F_CIB_CLIENTID); if(process == FALSE) { do_local_notify(request, client_id, call_options & cib_sync_call, from_peer); } else { do_local_notify(op_reply, client_id, call_options & cib_sync_call, from_peer); } } /* from now on we are the server */ if(needs_reply == FALSE || stand_alone) { /* nothing more to do... * this was a non-originating slave update */ crm_debug_2("Completed slave update"); } else if(rc == cib_ok && result_diff != NULL && !(call_options & cib_inhibit_bcast)) { send_peer_reply(request, result_diff, originator, TRUE); } else if(call_options & cib_discard_reply) { crm_debug_4("Caller isn't interested in reply"); } else if (from_peer) { if(is_update == FALSE || result_diff == NULL) { crm_debug_3("Request not broadcast: R/O call"); } else if(call_options & cib_inhibit_bcast) { crm_debug_3("Request not broadcast: inhibited"); } else if(rc != cib_ok) { crm_debug_3("Request not broadcast: call failed: %s", cib_error2string(rc)); } else { crm_debug_2("Directing reply to %s", originator); } send_peer_reply(op_reply, result_diff, originator, FALSE); } free_xml(op_reply); free_xml(result_diff); return; } xmlNode * cib_construct_reply(xmlNode *request, xmlNode *output, int rc) { int lpc = 0; xmlNode *reply = NULL; const char *name = NULL; const char *value = NULL; const char *names[] = { F_CIB_OPERATION, F_CIB_CALLID, F_CIB_CLIENTID, F_CIB_CALLOPTS }; crm_debug_4("Creating a basic reply"); reply = create_xml_node(NULL, "cib-reply"); crm_xml_add(reply, F_TYPE, T_CIB); for(lpc = 0; lpc < DIMOF(names); lpc++) { name = names[lpc]; value = crm_element_value(request, name); crm_xml_add(reply, name, value); } crm_xml_add_int(reply, F_CIB_RC, rc); if(output != NULL) { crm_debug_4("Attaching reply output"); add_message_xml(reply, F_CIB_CALLDATA, output); } return reply; } enum cib_errors cib_process_command(xmlNode *request, xmlNode **reply, xmlNode **cib_diff, gboolean privileged) { xmlNode *input = NULL; xmlNode *output = NULL; xmlNode *result_cib = NULL; xmlNode *current_cib = NULL; int call_type = 0; int call_options = 0; int log_level = LOG_DEBUG_4; const char *op = NULL; const char *section = NULL; enum cib_errors rc = cib_ok; enum cib_errors rc2 = cib_ok; gboolean send_r_notify = FALSE; gboolean global_update = FALSE; gboolean config_changed = FALSE; gboolean manage_counters = TRUE; CRM_ASSERT(cib_status == cib_ok); *reply = NULL; *cib_diff = NULL; current_cib = the_cib; /* Start processing the request... */ op = crm_element_value(request, F_CIB_OPERATION); crm_element_value_int(request, F_CIB_CALLOPTS, &call_options); rc = cib_get_operation_id(op, &call_type); if(rc == cib_ok) { rc = cib_op_can_run(call_type, call_options, privileged, global_update); } rc2 = cib_op_prepare(call_type, request, &input, §ion); if(rc == cib_ok) { rc = rc2; } if(rc != cib_ok) { crm_debug_2("Call setup failed: %s", cib_error2string(rc)); goto done; } else if(cib_op_modifies(call_type) == FALSE) { rc = cib_perform_op(op, call_options, cib_op_func(call_type), TRUE, section, request, input, FALSE, &config_changed, current_cib, &result_cib, NULL, &output); CRM_CHECK(result_cib == NULL, free_xml(result_cib)); goto done; } /* Handle a valid write action */ global_update = crm_is_true(crm_element_value(request, F_CIB_GLOBAL_UPDATE)); if(global_update) { manage_counters = FALSE; call_options |= cib_force_diff; CRM_CHECK(call_type == 3 || call_type == 4, crm_err("Call type: %d", call_type); crm_log_xml(LOG_ERR, "bad op", request)); } #ifdef SUPPORT_PRENOTIFY if((call_options & cib_inhibit_notify) == 0) { cib_pre_notify(call_options, op, the_cib, input); } #endif if(rc == cib_ok) { if(call_options & cib_inhibit_bcast) { /* skip */ crm_debug_2("Skipping update: inhibit broadcast"); manage_counters = FALSE; } rc = cib_perform_op(op, call_options, cib_op_func(call_type), FALSE, section, request, input, manage_counters, &config_changed, current_cib, &result_cib, cib_diff, &output); if(manage_counters == FALSE) { *cib_diff = diff_cib_object(current_cib, result_cib, FALSE); config_changed = cib_config_changed(*cib_diff); } } if(rc == cib_ok) { rc = activateCibXml(result_cib, config_changed, op); if(crm_str_eq(CIB_OP_REPLACE, op, TRUE)) { if(section == NULL) { send_r_notify = TRUE; } else if(safe_str_eq(section, XML_TAG_CIB)) { send_r_notify = TRUE; } else if(safe_str_eq(section, XML_CIB_TAG_NODES)) { send_r_notify = TRUE; } else if(safe_str_eq(section, XML_CIB_TAG_STATUS)) { send_r_notify = TRUE; } } else if(crm_str_eq(CIB_OP_ERASE, op, TRUE)) { send_r_notify = TRUE; } } else if(rc == cib_dtd_validation) { if(output != NULL) { crm_log_xml_info(output, "cib:output"); free_xml(output); } output = result_cib; } else { free_xml(result_cib); } if((call_options & cib_inhibit_notify) == 0) { const char *call_id = crm_element_value(request, F_CIB_CALLID); const char *client = crm_element_value(request, F_CIB_CLIENTNAME); #ifdef SUPPORT_POSTNOTIFY cib_post_notify(call_options, op, input, rc, the_cib); #endif cib_diff_notify(call_options, client, call_id, op, input, rc, *cib_diff); } if(send_r_notify) { const char *origin = crm_element_value(request, F_ORIG); cib_replace_notify(origin, the_cib, rc, *cib_diff); } if(rc != cib_ok) { log_level = LOG_DEBUG_4; if(rc == cib_dtd_validation && global_update) { log_level = LOG_WARNING; crm_log_xml_info(input, "cib:global_update"); } } else if(config_changed) { log_level = LOG_DEBUG_3; if(cib_is_master) { log_level = LOG_INFO; } } else if(cib_is_master) { log_level = LOG_DEBUG_2; } log_xml_diff(log_level, *cib_diff, "cib:diff"); done: if((call_options & cib_discard_reply) == 0) { *reply = cib_construct_reply(request, output, rc); /* crm_log_xml_info(*reply, "cib:reply"); */ } if(call_type >= 0) { cib_op_cleanup(call_type, call_options, &input, &output); } return rc; } int send_via_callback_channel(xmlNode *msg, const char *token) { cib_client_t *hash_client = NULL; enum cib_errors rc = cib_ok; crm_debug_3("Delivering msg %p to client %s", msg, token); if(token == NULL) { crm_err("No client id token, cant send message"); if(rc == cib_ok) { rc = cib_missing; } } else if(msg == NULL) { crm_err("No message to send"); rc = cib_reply_failed; } else { /* A client that left before we could reply is not really * _our_ error. Warn instead. */ hash_client = g_hash_table_lookup(client_list, token); if(hash_client == NULL) { crm_warn("Cannot find client for token %s", token); rc = cib_client_gone; } else if (crm_str_eq(hash_client->channel_name, "remote", FALSE)) { /* just hope it's alive */ } else if(hash_client->channel == NULL) { crm_err("Cannot find channel for client %s", token); rc = cib_client_corrupt; } } if(rc == cib_ok) { crm_debug_3("Delivering reply to client %s (%s)", token, hash_client->channel_name); if (crm_str_eq(hash_client->channel_name, "remote", FALSE)) { cib_send_remote_msg(hash_client->channel, msg, hash_client->encrypted); } else if(send_ipc_message(hash_client->channel, msg) == FALSE) { crm_warn("Delivery of reply to client %s/%s failed", hash_client->name, token); rc = cib_reply_failed; } } return rc; } gint cib_GCompareFunc(gconstpointer a, gconstpointer b) { const xmlNode *a_msg = a; const xmlNode *b_msg = b; int msg_a_id = 0; int msg_b_id = 0; const char *value = NULL; value = crm_element_value_const(a_msg, F_CIB_CALLID); msg_a_id = crm_parse_int(value, NULL); value = crm_element_value_const(b_msg, F_CIB_CALLID); msg_b_id = crm_parse_int(value, NULL); if(msg_a_id == msg_b_id) { return 0; } else if(msg_a_id < msg_b_id) { return -1; } return 1; } gboolean cib_process_disconnect(IPC_Channel *channel, cib_client_t *cib_client) { if (channel == NULL) { CRM_DEV_ASSERT(cib_client == NULL); } else if (cib_client == NULL) { crm_err("No client"); } else { CRM_DEV_ASSERT(channel->ch_status != IPC_CONNECT); crm_debug_2("Cleaning up after client disconnect: %s/%s/%s", crm_str(cib_client->name), cib_client->channel_name, cib_client->id); if(cib_client->id != NULL) { if(!g_hash_table_remove(client_list, cib_client->id)) { crm_err("Client %s not found in the hashtable", cib_client->name); } } } if(cib_shutdown_flag && g_hash_table_size(client_list) == 0) { crm_info("All clients disconnected..."); initiate_exit(); } return FALSE; } void cib_ha_peer_callback(HA_Message * msg, void* private_data) { xmlNode *xml = convert_ha_message(NULL, msg, __FUNCTION__); cib_peer_callback(xml, private_data); free_xml(xml); } void cib_peer_callback(xmlNode * msg, void* private_data) { crm_node_t *node = NULL; const char *reason = NULL; const char *originator = crm_element_value(msg, F_ORIG); if(originator == NULL || crm_str_eq(originator, cib_our_uname, TRUE)) { /* message is from ourselves */ return; } else if(crm_peer_cache == NULL) { reason = "membership not established"; goto bail; } node = crm_get_peer(0, originator); if(node == NULL || crm_is_member_active(node) == FALSE) { reason = "not in our membership"; goto bail; } if(crm_element_value(msg, F_CIB_CLIENTNAME) == NULL) { crm_xml_add(msg, F_CIB_CLIENTNAME, originator); } /* crm_log_xml(LOG_MSG, "Peer[inbound]", msg); */ cib_process_request(msg, FALSE, TRUE, TRUE, NULL); return; bail: if(reason) { const char *seq = crm_element_value(msg, F_SEQ); const char *op = crm_element_value(msg, F_CIB_OPERATION); crm_warn("Discarding %s message (%s) from %s: %s", op, seq, originator, reason); } } void cib_client_status_callback(const char * node, const char * client, const char * status, void * private) { crm_node_t *member = NULL; if(safe_str_eq(client, CRM_SYSTEM_CIB)) { crm_info("Status update: Client %s/%s now has status [%s]", node, client, status); if(safe_str_eq(status, JOINSTATUS)){ status = ONLINESTATUS; } else if(safe_str_eq(status, LEAVESTATUS)){ status = OFFLINESTATUS; } member = crm_get_peer(0, node); if(member == NULL) { /* Make sure it gets created */ const char *uuid = get_uuid(node); member = crm_update_peer(0, 0, 0, -1, 0, uuid, node, NULL, NULL); } crm_update_peer_proc(node, crm_proc_cib, status); } return; } #if SUPPORT_HEARTBEAT extern oc_ev_t *cib_ev_token; gboolean cib_ccm_dispatch(int fd, gpointer user_data) { int rc = 0; oc_ev_t *ccm_token = (oc_ev_t*)user_data; crm_debug_2("received callback"); rc = oc_ev_handle_event(ccm_token); if(0 == rc) { return TRUE; } crm_err("CCM connection appears to have failed: rc=%d.", rc); /* eventually it might be nice to recover and reconnect... but until then... */ crm_err("Exiting to recover from CCM connection failure"); exit(2); return FALSE; } int current_instance = 0; void cib_ccm_msg_callback( oc_ed_t event, void *cookie, size_t size, const void *data) { gboolean update_id = FALSE; const oc_ev_membership_t *membership = data; CRM_ASSERT(membership != NULL); crm_info("Processing CCM event=%s (id=%d)", ccm_event_name(event), membership->m_instance); if(current_instance > membership->m_instance) { crm_err("Membership instance ID went backwards! %d->%d", current_instance, membership->m_instance); CRM_ASSERT(current_instance <= membership->m_instance); } switch(event) { case OC_EV_MS_NEW_MEMBERSHIP: case OC_EV_MS_INVALID: update_id = TRUE; break; case OC_EV_MS_PRIMARY_RESTORED: update_id = TRUE; break; case OC_EV_MS_NOT_PRIMARY: crm_debug_2("Ignoring transitional CCM event: %s", ccm_event_name(event)); break; case OC_EV_MS_EVICTED: crm_err("Evicted from CCM: %s", ccm_event_name(event)); break; default: crm_err("Unknown CCM event: %d", event); } if(update_id) { unsigned int lpc = 0; CRM_CHECK(membership != NULL, return); current_instance = membership->m_instance; for(lpc=0; lpc < membership->m_n_out; lpc++) { crm_update_ccm_node( membership, lpc+membership->m_out_idx, CRM_NODE_LOST, current_instance); } for(lpc=0; lpc < membership->m_n_member; lpc++) { crm_update_ccm_node( membership, lpc+membership->m_memb_idx,CRM_NODE_ACTIVE, current_instance); } } oc_ev_callback_done(cookie); return; } #endif gboolean can_write(int flags) { return TRUE; } static gboolean cib_force_exit(gpointer data) { crm_notice("Forcing exit!"); terminate_cib(__FUNCTION__); return FALSE; } void initiate_exit(void) { int active = 0; xmlNode *leaving = NULL; active = crm_active_peers(crm_proc_cib); if(active < 2) { terminate_cib(__FUNCTION__); return; } crm_info("Sending disconnect notification to %d peers...", active); leaving = create_xml_node(NULL, "exit-notification"); crm_xml_add(leaving, F_TYPE, "cib"); crm_xml_add(leaving, F_CIB_OPERATION, "cib_shutdown_req"); send_cluster_message(NULL, crm_msg_cib, leaving, TRUE); free_xml(leaving); g_timeout_add(crm_get_msec("5s"), cib_force_exit, NULL); } extern int remote_fd; extern int remote_tls_fd; void terminate_cib(const char *caller) { if(remote_fd > 0) { close(remote_fd); } if(remote_tls_fd > 0) { close(remote_tls_fd); } #if SUPPORT_AIS if(is_openais_cluster()) { cib_ha_connection_destroy(NULL); return; } #endif #if SUPPORT_HEARTBEAT if(hb_conn != NULL) { crm_info("%s: Disconnecting heartbeat", caller); hb_conn->llc_ops->signoff(hb_conn, FALSE); } else { crm_err("%s: No heartbeat connection", caller); } #endif uninitializeCib(); crm_info("Exiting..."); if (mainloop != NULL && g_main_is_running(mainloop)) { g_main_quit(mainloop); } else { exit(LSB_EXIT_OK); } } diff --git a/configure.ac b/configure.ac index 3e6a0678c9..b10a0098e2 100644 --- a/configure.ac +++ b/configure.ac @@ -1,1477 +1,1477 @@ dnl dnl autoconf for Pacemaker dnl dnl License: GNU General Public License (GPL) dnl =============================================== dnl Bootstrap dnl =============================================== AC_PREREQ(2.53) dnl Suggested structure: dnl information on the package dnl checks for programs dnl checks for libraries dnl checks for header files dnl checks for types dnl checks for structures dnl checks for compiler characteristics dnl checks for library functions dnl checks for system services AC_INIT(pacemaker, 1.1.0, pacemaker@oss.clusterlabs.org) CRM_DTD_VERSION="1.0" PKG_FEATURES="" HB_PKG=heartbeat AC_CONFIG_AUX_DIR(.) AC_CANONICAL_HOST dnl Where #defines go (e.g. `AC_CHECK_HEADERS' below) dnl dnl Internal header: include/config.h dnl - Contains ALL defines dnl - include/config.h.in is generated automatically by autoheader dnl - NOT to be included in any header files except lha_internal.h dnl (which is also not to be included in any other header files) dnl dnl External header: include/crm_config.h dnl - Contains a subset of defines checked here dnl - Manually edit include/crm_config.h.in to have configure include dnl new defines dnl - Should not include HAVE_* defines dnl - Safe to include anywhere AM_CONFIG_HEADER(include/config.h include/crm_config.h) ALL_LINGUAS="en fr" AC_ARG_WITH(version, [ --with-version=version Override package version (if you're a packager needing to pretend) ], [ PACKAGE_VERSION="$withval" ]) AC_ARG_WITH(pkg-name, [ --with-pkg-name=name Override package name (if you're a packager needing to pretend) ], [ PACKAGE_NAME="$withval" ]) AM_INIT_AUTOMAKE($PACKAGE_NAME, $PACKAGE_VERSION) AC_DEFINE_UNQUOTED(PACEMAKER_VERSION, "$PACKAGE_VERSION", Current pacemaker version) dnl automake >= 1.11 offers --enable-silent-rules for suppressing the output from dnl normal compilation. When a failure occurs, it will then display the full dnl command line dnl Wrap in m4_ifdef to avoid breaking on older platforms m4_ifdef([AM_SILENT_RULES],[AM_SILENT_RULES]) CC_IN_CONFIGURE=yes export CC_IN_CONFIGURE LDD=ldd dnl ======================================================================== dnl Compiler characteristics dnl ======================================================================== AC_PROG_CC dnl Can force other with environment variable "CC". AM_PROG_CC_C_O AC_PROG_CC_STDC AC_LIBTOOL_DLOPEN dnl Enable dlopen support... AC_LIBLTDL_CONVENIENCE dnl make libltdl a convenience lib AC_PROG_LIBTOOL AC_C_STRINGIZE AC_TYPE_SIZE_T AC_CHECK_SIZEOF(char) AC_CHECK_SIZEOF(short) AC_CHECK_SIZEOF(int) AC_CHECK_SIZEOF(long) AC_CHECK_SIZEOF(long long) AC_STRUCT_TIMEZONE dnl =============================================== dnl Helpers dnl =============================================== cc_supports_flag() { local CFLAGS="$@" AC_MSG_CHECKING(whether $CC supports "$@") AC_COMPILE_IFELSE([int main(){return 0;}] ,[RC=0; AC_MSG_RESULT(yes)],[RC=1; AC_MSG_RESULT(no)]) return $RC } extract_header_define() { AC_MSG_CHECKING(for $2 in $1) Cfile=/tmp/extract_define.$2.${$} printf "#include \n" > ${Cfile}.c printf "#include <%s>\n" $1 >> ${Cfile}.c printf "int main(int argc, char **argv) { printf(\"%%s\", %s); return 0; }\n" $2 >> ${Cfile}.c $CC $CFLAGS ${Cfile}.c -o ${Cfile} value=`${Cfile}` AC_MSG_RESULT($value) printf $value rm -f ${Cfile}.c ${Cfile} } dnl =============================================== dnl Configure Options dnl =============================================== dnl Some systems, like Solaris require a custom package name AC_ARG_WITH(pkgname, [ --with-pkgname=name name for pkg (typically for Solaris) ], [ PKGNAME="$withval" ], [ PKGNAME="LXHAhb" ], ) AC_SUBST(PKGNAME) AC_ARG_ENABLE([ansi], [ --enable-ansi force GCC to compile to ANSI/ANSI standard for older compilers. [default=yes]]) AC_ARG_ENABLE([fatal-warnings], [ --enable-fatal-warnings very pedantic and fatal warnings for gcc [default=yes]]) AC_ARG_ENABLE([pretty], [ --enable-pretty Pretty-print compiler output unless there is an error [default=no]]) AC_ARG_ENABLE([quiet], [ --enable-quiet Supress make output unless there is an error [default=no]]) AC_ARG_ENABLE([thread-safe], [ --enable-thread-safe Enable some client libraries to be thread safe. [default=no]]) AC_ARG_ENABLE([bundled-ltdl], [ --enable-bundled-ltdl Configure, build and install the standalone ltdl library bundled with ${PACKAGE} [default=no]]) LTDL_LIBS="" AC_ARG_WITH(ais, [ --with-ais Support the OpenAIS messaging and membership layer ], [ SUPPORT_AIS=$withval ], [ SUPPORT_AIS=try ], ) AC_ARG_WITH(heartbeat, [ --with-heartbeat Support the Heartbeat messaging and membership layer ], [ SUPPORT_HEARTBEAT=$withval ], [ SUPPORT_HEARTBEAT=try ], ) AC_ARG_WITH(snmp, [ --with-snmp Support the SNMP protocol ], [ SUPPORT_SNMP=$withval ], [ SUPPORT_SNMP=try ], ) AC_ARG_WITH(esmtp, [ --with-esmtp Support the sending mail notifications with the esmtp library ], [ SUPPORT_ESMTP=$withval ], [ SUPPORT_ESMTP=try ], ) AISPREFIX="" AC_ARG_WITH(ais-prefix, [ --with-ais-prefix=DIR Prefix used when OpenAIS was installed [$prefix]], [ AISPREFIX=$withval ], [ AISPREFIX=$prefix ]) LCRSODIR="" AC_ARG_WITH(lcrso-dir, [ --with-lcrso-dir=DIR OpenAIS lcrso files. ], [ LCRSODIR="$withval" ]) INITDIR="" AC_ARG_WITH(initdir, [ --with-initdir=DIR directory for init (rc) scripts [${INITDIR}]], [ INITDIR="$withval" ]) dnl =============================================== dnl General Processing dnl =============================================== AC_SUBST(HB_PKG) INIT_EXT="" echo Our Host OS: $host_os/$host AC_MSG_NOTICE(Sanitizing prefix: ${prefix}) case $prefix in NONE) prefix=/usr;; esac AC_MSG_NOTICE(Sanitizing exec_prefix: ${exec_prefix}) case $exec_prefix in dnl For consistency with Heartbeat, map NONE->$prefix NONE) exec_prefix=$prefix;; prefix) exec_prefix=$prefix;; esac AC_MSG_NOTICE(Sanitizing ais_prefix: ${AISPREFIX}) case $AISPREFIX in dnl For consistency with Heartbeat, map NONE->$prefix NONE) AISPREFIX=$prefix;; prefix) AISPREFIX=$prefix;; esac AC_MSG_NOTICE(Sanitizing INITDIR: ${INITDIR}) case $INITDIR in prefix) INITDIR=$prefix;; "") AC_MSG_CHECKING(which init (rc) directory to use) for initdir in /etc/init.d /etc/rc.d/init.d /sbin/init.d \ /usr/local/etc/rc.d /etc/rc.d do if test -d $initdir then INITDIR=$initdir break fi done AC_MSG_RESULT($INITDIR);; esac AC_SUBST(INITDIR) AC_MSG_NOTICE(Sanitizing libdir: ${libdir}) case $libdir in dnl For consistency with Heartbeat, map NONE->$prefix *prefix*|NONE) AC_MSG_CHECKING(which lib directory to use) for aDir in lib64 lib do trydir="${exec_prefix}/${aDir}" if test -d ${trydir} then libdir=${trydir} break fi done AC_MSG_RESULT($libdir); ;; esac dnl Expand autoconf variables so that we dont end up with '${prefix}' dnl in #defines and python scripts dnl NOTE: Autoconf deliberately leaves them unexpanded to allow dnl make exec_prefix=/foo install dnl No longer being able to do this seems like no great loss to me... eval prefix="`eval echo ${prefix}`" eval exec_prefix="`eval echo ${exec_prefix}`" eval bindir="`eval echo ${bindir}`" eval sbindir="`eval echo ${sbindir}`" eval libexecdir="`eval echo ${libexecdir}`" eval datadir="`eval echo ${datadir}`" eval sysconfdir="`eval echo ${sysconfdir}`" eval sharedstatedir="`eval echo ${sharedstatedir}`" eval localstatedir="`eval echo ${localstatedir}`" eval libdir="`eval echo ${libdir}`" eval includedir="`eval echo ${includedir}`" eval oldincludedir="`eval echo ${oldincludedir}`" eval infodir="`eval echo ${infodir}`" eval mandir="`eval echo ${mandir}`" dnl Home-grown variables eval INITDIR="${INITDIR}" eval docdir="`eval echo ${docdir}`" if test x"${docdir}" = x""; then docdir=${datadir}/doc/${PACKAGE}-${VERSION} #docdir=${datadir}/doc/packages/${PACKAGE} fi AC_SUBST(docdir) for j in prefix exec_prefix bindir sbindir libexecdir datadir sysconfdir \ sharedstatedir localstatedir libdir includedir oldincludedir infodir \ mandir INITDIR docdir do dirname=`eval echo '${'${j}'}'` if test ! -d "$dirname" then AC_MSG_WARN([$j directory ($dirname) does not exist!]) fi done dnl This OS-based decision-making is poor autotools practice; dnl feature-based mechanisms are strongly preferred. dnl dnl So keep this section to a bare minimum; regard as a "necessary evil". case "$host_os" in *bsd*) LIBS="-L/usr/local/lib" CPPFLAGS="$CPPFLAGS -I/usr/local/include" INIT_EXT=".sh" ;; *solaris*) ;; *linux*) AC_DEFINE_UNQUOTED(ON_LINUX, 1, Compiling for Linux platform) CFLAGS="$CFLAGS -I${prefix}/include" ;; darwin*) AC_DEFINE_UNQUOTED(ON_DARWIN, 1, Compiling for Darwin platform) LIBS="$LIBS -L${prefix}/lib" CFLAGS="$CFLAGS -I${prefix}/include" ;; esac dnl Eventually remove this CFLAGS="$CFLAGS -I${prefix}/include/heartbeat" AC_SUBST(INIT_EXT) AC_DEFINE_UNQUOTED(HA_LOG_FACILITY, LOG_DAEMON, Default logging facility) AC_MSG_NOTICE(Host CPU: $host_cpu) case "$host_cpu" in ppc64|powerpc64) case $CFLAGS in *powerpc64*) ;; *) if test "$GCC" = yes; then CFLAGS="$CFLAGS -m64" fi ;; esac esac AC_MSG_CHECKING(which format is needed to print uint64_t) case "$host_cpu" in s390x)U64T="%lu";; *64*) U64T="%lu";; *) U64T="%llu";; esac AC_MSG_RESULT($U64T) AC_DEFINE_UNQUOTED(U64T, "$U64T", Correct printf format for logging uint64_t) AC_CHECK_HEADERS(hb_config.h) AC_CHECK_HEADERS(glue_config.h) GLUE_HEADER=none if test "$ac_cv_header_glue_config_h" = "yes"; then GLUE_HEADER=glue_config.h elif test "$ac_cv_header_hb_config_h" = "yes"; then GLUE_HEADER=hb_config.h else AC_MSG_FAILURE(Core development headers were not found) fi dnl Variables needed for substitution CRM_DTD_DIRECTORY="${datadir}/pacemaker" AC_DEFINE_UNQUOTED(CRM_DTD_DIRECTORY,"$CRM_DTD_DIRECTORY", Location for the Pacemaker Relax-NG Schema) AC_SUBST(CRM_DTD_DIRECTORY) AC_DEFINE_UNQUOTED(CRM_DTD_VERSION,"$CRM_DTD_VERSION", Current version of the Pacemaker Relax-NG Schema) AC_SUBST(CRM_DTD_VERSION) CRM_DAEMON_USER=`extract_header_define $GLUE_HEADER HA_CCMUSER` AC_DEFINE_UNQUOTED(CRM_DAEMON_USER,"$CRM_DAEMON_USER", User to run Pacemaker daemons as) AC_SUBST(CRM_DAEMON_USER) CRM_DAEMON_GROUP=`extract_header_define $GLUE_HEADER HA_APIGROUP` AC_DEFINE_UNQUOTED(CRM_DAEMON_GROUP,"$CRM_DAEMON_GROUP", Group to run Pacemaker daemons as) AC_SUBST(CRM_DAEMON_GROUP) CRM_STATE_DIR=${localstatedir}/run/crm AC_DEFINE_UNQUOTED(CRM_STATE_DIR,"$CRM_STATE_DIR", Where to keep state files and sockets) AC_SUBST(CRM_STATE_DIR) PE_STATE_DIR="${localstatedir}/lib/pengine" AC_DEFINE_UNQUOTED(PE_STATE_DIR,"$PE_STATE_DIR", Where to keep PEngine outputs) AC_SUBST(PE_STATE_DIR) dnl Eventually move out of the heartbeat dir tree and create compatability code CRM_CONFIG_DIR="${localstatedir}/lib/heartbeat/crm" AC_DEFINE_UNQUOTED(CRM_CONFIG_DIR,"$CRM_CONFIG_DIR", Where to keep CIB configuration files) AC_SUBST(CRM_CONFIG_DIR) dnl Eventually move out of the heartbeat dir tree and create symlinks when needed CRM_DAEMON_DIR=`extract_header_define $GLUE_HEADER HA_LIBHBDIR` AC_DEFINE_UNQUOTED(CRM_DAEMON_DIR,"$CRM_DAEMON_DIR", Location for Pacemaker daemons) AC_SUBST(CRM_DAEMON_DIR) dnl Needed so that the AIS plugin can clear out the directory as Heartbeat does HA_STATE_DIR=`extract_header_define $GLUE_HEADER HA_VARRUNDIR` AC_DEFINE_UNQUOTED(HA_STATE_DIR,"$HA_STATE_DIR", Where Heartbeat keeps state files and sockets) AC_SUBST(HA_STATE_DIR) dnl Needed for the location of hostcache in CTS.py HA_VARLIBHBDIR=`extract_header_define $GLUE_HEADER HA_VARLIBHBDIR` AC_SUBST(HA_VARLIBHBDIR) AC_DEFINE_UNQUOTED(UUID_FILE,"$localstatedir/lib/heartbeat/hb_uuid", Location of Heartbeat's UUID file) OCF_ROOT_DIR=`extract_header_define $GLUE_HEADER OCF_ROOT_DIR` if test "X$OCF_ROOT_DIR" = X; then AC_MSG_ERROR(Could not locate OCF directory) fi AC_SUBST(OCF_ROOT_DIR) OCF_RA_DIR=`extract_header_define $GLUE_HEADER OCF_RA_DIR` AC_DEFINE_UNQUOTED(OCF_RA_DIR,"$OCF_RA_DIR", Location for OCF RAs) AC_SUBST(OCF_RA_DIR) dnl Extract this value from glue_config.h once we no longer support anything else STONITH_PLUGIN_DIR="$libdir/stonith/plugins/stonith/" AC_DEFINE_UNQUOTED(STONITH_PLUGIN_DIR,"$STONITH_PLUGIN_DIR", Location for Stonith plugins) AC_SUBST(STONITH_PLUGIN_DIR) RH_STONITH_DIR="$sbindir" AC_DEFINE_UNQUOTED(RH_STONITH_DIR,"$RH_STONITH_DIR", Location for Red Hat Stonith agents) RH_STONITH_PREFIX="fence_" AC_DEFINE_UNQUOTED(RH_STONITH_PREFIX,"$RH_STONITH_PREFIX", Prefix for Red Hat Stonith agents) AC_PATH_PROGS(HG, hg false) AC_MSG_CHECKING(build version) BUILD_VERSION=unknown if test -f $srcdir/.hg_archival.txt; then BUILD_VERSION=`cat $srcdir/.hg_archival.txt | awk '/node:/ { print $2 }'` elif test -x $HG -a -d .hg; then BUILD_VERSION=`$HG id -itb` if test $? != 0; then BUILD_VERSION=unknown fi fi AC_DEFINE_UNQUOTED(BUILD_VERSION, "$BUILD_VERSION", Build version) AC_MSG_RESULT($BUILD_VERSION) AC_SUBST(BUILD_VERSION) dnl =============================================== dnl Program Paths dnl =============================================== PATH="$PATH:/sbin:/usr/sbin:/usr/local/sbin:/usr/local/bin" export PATH dnl Replacing AC_PROG_LIBTOOL with AC_CHECK_PROG because LIBTOOL dnl was NOT being expanded all the time thus causing things to fail. AC_CHECK_PROGS(LIBTOOL, glibtool libtool libtool15 libtool13) AM_PATH_PYTHON AC_CHECK_PROGS(MAKE, gmake make) AC_PATH_PROGS(HTML2TXT, lynx w3m) AC_PATH_PROGS(HELP2MAN, help2man) AC_PATH_PROGS(POD2MAN, pod2man, pod2man) AC_PATH_PROGS(ASCIIDOC, asciidoc) AC_PATH_PROGS(PUBLICAN, publican) AC_PATH_PROGS(FOP, fop) AC_PATH_PROGS(SSH, ssh, /usr/bin/ssh) AC_PATH_PROGS(SCP, scp, /usr/bin/scp) AC_PATH_PROGS(HG, hg, /bin/false) AC_PATH_PROGS(TAR, tar) AC_PATH_PROGS(MD5, md5) AC_PATH_PROGS(TEST, test) AC_PATH_PROGS(PKGCONFIG, pkg-config) AC_PATH_PROGS(XML2CONFIG, xml2-config) AC_PATH_PROGS(VALGRIND_BIN, valgrind, /usr/bin/valgrind) AC_DEFINE_UNQUOTED(VALGRIND_BIN, "$VALGRIND_BIN", Valgrind command) if test x"${LIBTOOL}" = x""; then AC_MSG_ERROR(You need (g)libtool installed in order to build ${PACKAGE}) fi if test x"${MAKE}" = x""; then AC_MSG_ERROR(You need (g)make installed in order to build ${PACKAGE}) fi AM_CONDITIONAL(BUILD_HELP, test x"${HELP2MAN}" != x"") if test x"${HELP2MAN}" != x""; then PKG_FEATURES="$PKG_FEATURES manpages" fi AM_CONDITIONAL(BUILD_ASCIIDOC, test x"${ASCIIDOC}" != x"") if test x"${ASCIIDOC}" != x""; then PKG_FEATURES="$PKG_FEATURES asciidoc" fi AM_CONDITIONAL(BUILD_DOCBOOK, test ${PUBLICAN} != x"") if test ${PUBLICAN} != x""; then PKG_FEATURES="$PKG_FEATURES publican" fi dnl =============================================== dnl Libraries dnl =============================================== AC_CHECK_LIB(socket, socket) dnl -lsocket AC_CHECK_LIB(c, dlopen) dnl if dlopen is in libc... AC_CHECK_LIB(dl, dlopen) dnl -ldl (for Linux) AC_CHECK_LIB(rt, sched_getscheduler) dnl -lrt (for Tru64) AC_CHECK_LIB(gnugetopt, getopt_long) dnl -lgnugetopt ( if available ) AC_CHECK_LIB(pam, pam_start) dnl -lpam (if available) AC_CHECK_LIB(uuid, uuid_parse) dnl e2fsprogs AC_CHECK_LIB(uuid, uuid_create) dnl ossp if test x"${PKGCONFIG}" = x""; then AC_MSG_ERROR(You need pkgconfig installed in order to build ${PACKAGE}) fi dnl dnl On many systems libcrypto is needed when linking against libsnmp. dnl Check to see if it exists, and if so use it. dnl AC_CHECK_LIB(crypto, CRYPTO_free, CRYPTOLIB="-lcrypto",) AC_SUBST(CRYPTOLIB) if test "x${enable_thread_safe}" = "xyes"; then GPKGNAME="gthread-2.0" else GPKGNAME="glib-2.0" fi if $PKGCONFIG --exists $GPKGNAME then GLIBCONFIG="$PKGCONFIG $GPKGNAME" else set -x echo PKG_CONFIG_PATH=$PKG_CONFIG_PATH $PKGCONFIG --exists $GPKGNAME; echo $? $PKGCONFIG --cflags $GPKGNAME; echo $? $PKGCONFIG $GPKGNAME; echo $? set +x AC_MSG_ERROR(You need glib2-devel installed in order to build ${PACKAGE}) fi AC_MSG_RESULT(using $GLIBCONFIG) # # Where is dlopen? # if test "$ac_cv_lib_c_dlopen" = yes; then LIBADD_DL="" elif test "$ac_cv_lib_dl_dlopen" = yes; then LIBADD_DL=-ldl else LIBADD_DL=${lt_cv_dlopen_libs} fi dnl dnl Check for location of gettext dnl dnl On at least Solaris 2.x, where it is in libc, specifying lintl causes dnl grief. Ensure minimal result, not the sum of all possibilities. dnl And do libc first. dnl Known examples: dnl c: Linux, Solaris 2.6+ dnl intl: BSD, AIX AC_CHECK_LIB(c, gettext) if test x$ac_cv_lib_c_gettext != xyes; then AC_CHECK_LIB(intl, gettext) fi if test x$ac_cv_lib_c_gettext != xyes -a x$ac_cv_lib_intl_gettext != xyes; then AC_MSG_ERROR(You need gettext installed in order to build ${PACKAGE}) fi if test "X$GLIBCONFIG" != X; then AC_MSG_CHECKING(for special glib includes: ) GLIBHEAD=`$GLIBCONFIG --cflags` AC_MSG_RESULT($GLIBHEAD) CPPFLAGS="$CPPFLAGS $GLIBHEAD" AC_MSG_CHECKING(for glib library flags) GLIBLIB=`$GLIBCONFIG --libs` AC_MSG_RESULT($GLIBLIB) LIBS="$LIBS $GLIBLIB" fi dnl ======================================================================== dnl Headers dnl ======================================================================== AC_HEADER_STDC AC_CHECK_HEADERS(arpa/inet.h) AC_CHECK_HEADERS(asm/types.h) AC_CHECK_HEADERS(assert.h) AC_CHECK_HEADERS(auth-client.h) AC_CHECK_HEADERS(ctype.h) AC_CHECK_HEADERS(dirent.h) AC_CHECK_HEADERS(errno.h) AC_CHECK_HEADERS(fcntl.h) AC_CHECK_HEADERS(getopt.h) AC_CHECK_HEADERS(glib.h) AC_CHECK_HEADERS(grp.h) AC_CHECK_HEADERS(limits.h) AC_CHECK_HEADERS(linux/errqueue.h) AC_CHECK_HEADERS(malloc.h) AC_CHECK_HEADERS(netdb.h) AC_CHECK_HEADERS(netinet/in.h) AC_CHECK_HEADERS(netinet/ip.h) AC_CHECK_HEADERS(pam/pam_appl.h) AC_CHECK_HEADERS(pthread.h) AC_CHECK_HEADERS(pwd.h) AC_CHECK_HEADERS(security/pam_appl.h) AC_CHECK_HEADERS(sgtty.h) AC_CHECK_HEADERS(signal.h) AC_CHECK_HEADERS(stdarg.h) AC_CHECK_HEADERS(stddef.h) AC_CHECK_HEADERS(stdio.h) AC_CHECK_HEADERS(stdlib.h) AC_CHECK_HEADERS(string.h) AC_CHECK_HEADERS(strings.h) AC_CHECK_HEADERS(sys/dir.h) AC_CHECK_HEADERS(sys/ioctl.h) AC_CHECK_HEADERS(sys/param.h) AC_CHECK_HEADERS(sys/poll.h) AC_CHECK_HEADERS(sys/resource.h) AC_CHECK_HEADERS(sys/select.h) AC_CHECK_HEADERS(sys/socket.h) AC_CHECK_HEADERS(sys/sockio.h) AC_CHECK_HEADERS(sys/stat.h) AC_CHECK_HEADERS(sys/time.h) AC_CHECK_HEADERS(sys/timeb.h) AC_CHECK_HEADERS(sys/types.h) AC_CHECK_HEADERS(sys/uio.h) AC_CHECK_HEADERS(sys/un.h) AC_CHECK_HEADERS(sys/utsname.h) AC_CHECK_HEADERS(sys/wait.h) AC_CHECK_HEADERS(time.h) AC_CHECK_HEADERS(unistd.h) AC_CHECK_HEADERS(winsock.h) dnl These headers need prerequisits before the tests will pass dnl AC_CHECK_HEADERS(net/if.h) dnl AC_CHECK_HEADERS(netinet/icmp6.h) dnl AC_CHECK_HEADERS(netinet/ip6.h) dnl AC_CHECK_HEADERS(netinet/ip_icmp.h) AC_MSG_CHECKING(for special libxml2 includes) if test "x$XML2CONFIG" = "x"; then AC_MSG_ERROR(libxml2 config not found) else XML2HEAD="`$XML2CONFIG --cflags`" AC_MSG_RESULT($XML2HEAD) AC_CHECK_LIB(xml2, xmlReadMemory) AC_CHECK_LIB(xslt, xsltApplyStylesheet) fi CPPFLAGS="$CPPFLAGS $XML2HEAD" AC_CHECK_HEADERS(libxml/xpath.h) AC_CHECK_HEADERS(libxslt/xslt.h) if test "$ac_cv_header_libxml_xpath_h" != "yes"; then AC_MSG_ERROR(The libxml developement headers were not found) fi if test "$ac_cv_header_libxslt_xslt_h" != "yes"; then AC_MSG_ERROR(The libxslt developement headers were not found) fi dnl ======================================================================== dnl Structures dnl ======================================================================== AC_CHECK_MEMBERS([struct tm.tm_gmtoff],,,[[#include ]]) dnl ======================================================================== dnl Functions dnl ======================================================================== AC_CHECK_FUNCS(g_log_set_default_handler) AC_CHECK_FUNCS(getopt, AC_DEFINE(HAVE_DECL_GETOPT, 1, [Have getopt function])) dnl ======================================================================== dnl ltdl dnl ======================================================================== AC_CHECK_LIB(ltdl, lt_dlopen, [LTDL_foo=1]) if test "x${enable_bundled_ltdl}" = "xyes"; then if test $ac_cv_lib_ltdl_lt_dlopen = yes; then AC_MSG_NOTICE([Disabling usage of installed ltdl]) fi ac_cv_lib_ltdl_lt_dlopen=no fi LIBLTDL_DIR="" if test $ac_cv_lib_ltdl_lt_dlopen != yes ; then AC_MSG_NOTICE([Installing local ltdl]) LIBLTDL_DIR=libltdl ( cd $srcdir ; $TAR -xvf libltdl.tar ) if test "$?" -ne 0; then AC_MSG_ERROR([$TAR of libltdl.tar in $srcdir failed]) fi AC_CONFIG_SUBDIRS(libltdl) else LIBS="$LIBS -lltdl" AC_MSG_NOTICE([Using installed ltdl]) INCLTDL="" LIBLTDL="" fi AC_SUBST(INCLTDL) AC_SUBST(LIBLTDL) AC_SUBST(LIBLTDL_DIR) dnl ======================================================================== dnl bzip2 dnl ======================================================================== AC_CHECK_HEADERS(bzlib.h) AC_CHECK_LIB(bz2, BZ2_bzBuffToBuffCompress) if test x$ac_cv_lib_bz2_BZ2_bzBuffToBuffCompress != xyes ; then AC_MSG_ERROR(BZ2 libraries not found) fi if test x$ac_cv_header_bzlib_h != xyes; then AC_MSG_ERROR(BZ2 Development headers not found) fi dnl ======================================================================== dnl ncurses dnl ======================================================================== dnl dnl A few OSes (e.g. Linux) deliver a default "ncurses" alongside "curses". dnl Many non-Linux deliver "curses"; sites may add "ncurses". dnl dnl However, the source-code recommendation for both is to #include "curses.h" dnl (i.e. "ncurses" still wants the include to be simple, no-'n', "curses.h"). dnl dnl ncurse takes precedence. dnl AC_CHECK_HEADERS(curses.h) AC_CHECK_HEADERS(curses/curses.h) AC_CHECK_HEADERS(ncurses.h) AC_CHECK_HEADERS(ncurses/ncurses.h) dnl Although n-library is preferred, only look for it if the n-header was found. CURSESLIBS='' if test "$ac_cv_header_ncurses_h" = "yes"; then AC_CHECK_LIB(ncurses, printw, [CURSESLIBS='-lncurses'; AC_DEFINE(HAVE_LIBNCURSES,1, have ncurses library)] ) fi if test "$ac_cv_header_ncurses_ncurses_h" = "yes"; then AC_CHECK_LIB(ncurses, printw, [CURSESLIBS='-lncurses'; AC_DEFINE(HAVE_LIBNCURSES,1, have ncurses library)] ) fi dnl Only look for non-n-library if there was no n-library. if test X"$CURSESLIBS" = X"" -a "$ac_cv_header_curses_h" = "yes"; then AC_CHECK_LIB(curses, printw, [CURSESLIBS='-lcurses'; AC_DEFINE(HAVE_LIBCURSES,1, have curses library)] ) fi dnl Only look for non-n-library if there was no n-library. if test X"$CURSESLIBS" = X"" -a "$ac_cv_header_curses_curses_h" = "yes"; then AC_CHECK_LIB(curses, printw, [CURSESLIBS='-lcurses'; AC_DEFINE(HAVE_LIBCURSES,1, have curses library)] ) fi if test "x$CURSESLIBS" != "x"; then PKG_FEATURES="$PKG_FEATURES ncurses" fi dnl Check for printw() prototype compatibility if test X"$CURSESLIBS" != X"" && cc_supports_flag -Wcast-qual && cc_supports_flag -Werror; then AC_MSG_CHECKING(whether printw() requires argument of "const char *") ac_save_LIBS=$LIBS LIBS="$CURSESLIBS $LIBS" ac_save_CFLAGS=$CFLAGS CFLAGS="-Wcast-qual -Werror" AC_LINK_IFELSE( [AC_LANG_PROGRAM( [ #if defined(HAVE_CURSES_H) # include #elif defined(HAVE_NCURSES_H) # include #endif ], [printw((const char *)"Test");] )], [ac_cv_compatible_printw=yes], [ac_cv_compatible_printw=no] ) LIBS=$ac_save_LIBS CFLAGS=$ac_save_CFLAGS AC_MSG_RESULT([$ac_cv_compatible_printw]) if test "$ac_cv_compatible_printw" = no; then AC_MSG_WARN([The printw() function of your ncurses or curses library is old, we will disable usage of the library. If you want to use this library anyway, please update to newer version of the library, ncurses 5.4 or later is recommended. You can get the library from http://www.gnu.org/software/ncurses/.]) AC_MSG_NOTICE([Disabling curses]) AC_DEFINE(HAVE_INCOMPATIBLE_PRINTW, 1, [Do we have incompatible printw() in curses library?]) fi fi AC_SUBST(CURSESLIBS) dnl ======================================================================== dnl Cluster infrastructure - Heartbeat dnl ======================================================================== dnl On Debian, AC_CHECK_LIBS fail if a library has any unresolved symbols dnl So check for all the depenancies (so they're added to LIBS) before checking for -lplumb AC_CHECK_LIB(pils, PILLoadPlugin) AC_CHECK_LIB(plumb, G_main_add_IPC_Channel) if test x"$ac_cv_lib_plumb_G_main_add_IPC_Channel" != x"yes"; then AC_MSG_FAILURE(Core Heartbeat utility libraries not found: $ac_cv_lib_plumb_G_main_add_IPC_Channel) fi dnl Compatability checks AC_CHECK_FUNCS(msgfromIPC_timeout) AC_CHECK_MEMBERS([struct lrm_ops.fail_rsc],,,[[#include ]]) dnl ======================================================================== dnl Cluster stack - Heartbeat dnl ======================================================================== case $SUPPORT_HEARTBEAT in 1|yes|true) AC_CHECK_LIB(hbclient, ll_cluster_new, [SUPPORT_HEARTBEAT=1], [AC_MSG_FAILURE(Unable to support Heartbeat: client libraries not found)]);; try) AC_CHECK_LIB(hbclient, ll_cluster_new, [SUPPORT_HEARTBEAT=1], [SUPPORT_HEARTBEAT=0]);; *) SUPPORT_HEARTBEAT=0;; esac AM_CONDITIONAL(BUILD_HEARTBEAT_SUPPORT, test $SUPPORT_HEARTBEAT = 1) AC_DEFINE_UNQUOTED(SUPPORT_HEARTBEAT, $SUPPORT_HEARTBEAT, Support the Heartbeat messaging and membership layer) dnl ======================================================================== dnl Cluster stack - OpenAIS dnl ======================================================================== AISLIB="" dnl Normalize the values case $SUPPORT_AIS in 1|yes|true) missingisfatal=1;; try) missingisfatal=0;; *) SUPPORT_AIS=no;; esac AC_MSG_CHECKING(for native AIS) AISMSGLIB="" AIS_VERSION="none" COROSYNC_PKG="$PKGCONFIG libcoroipcc" if test $SUPPORT_AIS = no; then AC_MSG_RESULT(no... not requested.) else AC_MSG_RESULT($SUPPORT_AIS, with '$AISPREFIX') AC_CHECK_HEADERS(openais/saAis.h) AC_CHECK_HEADERS(corosync/coroipcc.h) $COROSYNC_PKG --exists if test $? = 0; then AIS_VERSION="corosync" elif test "$ac_cv_header_openais_saAis_h" = "yes"; then AIS_VERSION="whitetank" else aisreason="Whitetank headers not found" fi fi if test $AIS_VERSION != "none"; then AC_MSG_CHECKING(for OpenAIS branch) AC_MSG_RESULT($AIS_VERSION) fi if test $AIS_VERSION = "corosync"; then if test "$ac_cv_header_corosync_coroipcc_h" != "yes"; then AIS_VERSION="none" aisreason="Corosync headers not found" fi saveLIBS="$LIBS" LIBS="$LIBS `$COROSYNC_PKG --libs-only-L`" AC_CHECK_LIB(coroipcc, coroipcc_msg_send_reply_receive, []) LIBS="$saveLIBS" if test $ac_cv_lib_coroipcc_coroipcc_msg_send_reply_receive != yes; then AC_MSG_RESULT(Cannot locate AIS messaging library) aisreason="requred Corosync libraries not found" AIS_VERSION="none" fi fi dnl continue? if test $AIS_VERSION = "whitetank"; then dnl Find it in lib, lib64, or wherever it wants to live... AC_MSG_CHECKING(location of OpenAIS libraries) dnl CoroSync location alib=`ls ${AISPREFIX}/*/libcpg.so | head -n 1` if test -z "$alib"; then dnl Whitetank location alib=`ls ${AISPREFIX}/*/*/libcpg.so | head -n 1` fi AISLIB=`dirname $alib` AC_MSG_RESULT($AISLIB) if test "x$AISLIB" = "x"; then AC_MSG_WARN(Use --with-ais-prefix to specify the prefix OpenAIS was installed with) aisreason="library directory not found" AIS_VERSION="none" elif test ! -d "$AISLIB"; then AC_MSG_WARN(Use --with-ais-prefix to specify the prefix OpenAIS was installed with) aisreason="specified library directory does not exist" AIS_VERSION="none" fi fi dnl continue? if test $AIS_VERSION = "whitetank"; then AC_MSG_CHECKING(location of OpenAIS plugins) if test -z "$LCRSODIR"; then LCRSODIR="$libexecdir/lcrso" alib=`ls ${AISPREFIX}/*/lcrso/objdb.lcrso | head -n 1` LCRSODIR=`dirname $alib` fi AC_MSG_RESULT($LCRSODIR) if test "x$LCRSODIR" = "x"; then AC_MSG_RESULT(Invalid. Please specify the correct location with --with-lcrso-dir) aisreason="plugin directory not found" AIS_VERSION="none" elif test ! -d "$LCRSODIR"; then AC_MSG_RESULT(Invalid. Please specify the correct location with --with-lcrso-dir) aisreason="specified plugin directory does not exist" AIS_VERSION="none" fi fi dnl continue? if test $AIS_VERSION = "whitetank"; then dnl Don't add the messaging library to LIBS since most daemons don't need/use it saveLIBS="$LIBS" LIBS="$LIBS -L${AISLIB} -R${AISLIB}" AC_CHECK_LIB(SaMsg, saSendReceiveReply, []) AC_CHECK_LIB(SaMsg, openais_msg_send_reply_receive, []) if test $ac_cv_lib_SaMsg_openais_msg_send_reply_receive = yes; then : OpenAIS elif test $ac_cv_lib_SaMsg_saSendReceiveReply = yes; then : OpenAIS AC_DEFINE_UNQUOTED(TRADITIONAL_AIS_IPC, 1, "Use the 'old' AIS IPC interface") else AC_MSG_RESULT(Cannot locate AIS messaging library) aisreason="requred libraries not found" AIS_VERSION="none" fi LIBS="$saveLIBS" fi SUPPORT_AIS=1 case $AIS_VERSION in corosync) AC_DEFINE_UNQUOTED(AIS_COROSYNC, 1, "AIS target is the corosync series") LCRSODIR=`$PKGCONFIG corosync --variable=lcrsodir` CFLAGS="$CFLAGS `$COROSYNC_PKG --cflags`" AISMSGLIB=`$COROSYNC_PKG --libs` ;; whitetank) AC_DEFINE_UNQUOTED(AIS_WHITETANK, 1, "AIS target is the whitetank series") CFLAGS="$CFLAGS -I$AISPREFIX/include/openais" AISMSGLIB="-L${AISLIB} -R${AISLIB} -lSaMsg" ;; none) SUPPORT_AIS=0 if test "x$aisreason" != x; then if test $missingisfatal = 0; then AC_MSG_WARN(Unable to support OpenAIS: $aisreason) else AC_MSG_FAILURE(Unable to support OpenAIS: $aisreason) fi fi ;; *) AC_MSG_FAILURE(Unknown OpenAIS branch: $AIS_VERSION);; esac AC_DEFINE_UNQUOTED(SUPPORT_AIS, $SUPPORT_AIS, Support the OpenAIS messaging and membership layer) AM_CONDITIONAL(BUILD_AIS_SUPPORT, test $SUPPORT_AIS = 1) dnl dnl Cluster stack - Sanity dnl STACKS="" CLUSTERLIBS="" if test $SUPPORT_HEARTBEAT = 1; then STACKS="$STACKS heartbeat" CLUSTERLIBS="$CLUSTERLIBS -lhbclient -lccmclient" fi if test $SUPPORT_AIS = 1; then STACKS="$STACKS $AIS_VERSION" CLUSTERLIBS="$CLUSTERLIBS ${AISMSGLIB}" else AISPREFIX="" LCRSODIR="$libdir" fi PKG_FEATURES="$PKG_FEATURES$STACKS" AC_MSG_CHECKING(for supported stacks) if test x"$STACKS" = x; then AC_MSG_FAILURE(You must choose at least one cluster stack to support) fi AC_MSG_RESULT($STACKS) AC_SUBST(CLUSTERLIBS) AC_SUBST(LCRSODIR) dnl ======================================================================== dnl SNMP dnl ======================================================================== case $SUPPORT_SNMP in 1|yes|true) missingisfatal=1;; try) missingisfatal=0;; *) SUPPORT_SNMP=no;; esac SNMPLIB="" AC_MSG_CHECKING(for snmp support) if test $SUPPORT_SNMP = no; then AC_MSG_RESULT(no... not requested.) SUPPORT_SNMP=0 else SNMPCONFIG="" AC_MSG_RESULT($SUPPORT_SNMP) AC_CHECK_HEADERS(net-snmp/net-snmp-config.h) if test "x${ac_cv_header_net_snmp_net_snmp_config_h}" != "xyes"; then SUPPORT_SNMP="no" fi if test $SUPPORT_SNMP != no; then AC_PATH_PROGS(SNMPCONFIG, net-snmp-config) if test "X${SNMPCONFIG}" = "X"; then AC_MSG_RESULT(You need the net_snmp development package to continue.) SUPPORT_SNMP=no fi fi if test $SUPPORT_SNMP != no; then AC_MSG_CHECKING(for special snmp libraries) SNMPLIBS=`$SNMPCONFIG --agent-libs` AC_MSG_RESULT($SNMPLIBS) fi if test $SUPPORT_SNMP != no; then savedLibs=$LIBS LIBS="$LIBS $SNMPLIBS" AC_CHECK_FUNCS(netsnmp_transport_open_client) if test $ac_cv_func_netsnmp_transport_open_client != yes; then SUPPORT_SNMP=no fi LIBS=$savedLibs fi if test $SUPPORT_SNMP = no; then SUPPORT_SNMP=0 if test $missingisfatal = 0; then AC_MSG_WARN(Unable to support SNMP) else AC_MSG_FAILURE(Unable to support SNMP) fi else SUPPORT_SNMP=1 fi fi if test $SUPPORT_SNMP = 1; then PKG_FEATURES="$PKG_FEATURES snmp" fi AC_SUBST(SNMPLIBS) AM_CONDITIONAL(ENABLE_SNMP, test "$SUPPORT_SNMP" = "1") AC_DEFINE_UNQUOTED(ENABLE_SNMP, $SUPPORT_SNMP, Build in support for sending SNMP traps) dnl ======================================================================== dnl ESMTP dnl ======================================================================== case $SUPPORT_ESMTP in 1|yes|true) missingisfatal=1;; try) missingisfatal=0;; *) SUPPORT_ESMTP=no;; esac ESMTPLIB="" AC_MSG_CHECKING(for esmtp support) if test $SUPPORT_ESMTP = no; then AC_MSG_RESULT(no... not requested.) SUPPORT_ESMTP=0 else ESMTPCONFIG="" AC_MSG_RESULT($SUPPORT_ESMTP) AC_CHECK_HEADERS(libesmtp.h) if test "x${ac_cv_header_libesmtp_h}" != "xyes"; then ENABLE_ESMTP="no" fi if test $SUPPORT_ESMTP != no; then AC_PATH_PROGS(ESMTPCONFIG, libesmtp-config) if test "X${ESMTPCONFIG}" = "X"; then AC_MSG_RESULT(You need the libesmtp development package to continue.) SUPPORT_ESMTP=no fi fi if test $SUPPORT_ESMTP != no; then AC_MSG_CHECKING(for special esmtp libraries) ESMTPLIBS=`$ESMTPCONFIG --libs | tr '\n' ' '` AC_MSG_RESULT($ESMTPLIBS) fi if test $SUPPORT_ESMTP = no; then SUPPORT_ESMTP=0 if test $missingisfatal = 0; then AC_MSG_WARN(Unable to support ESMTP) else AC_MSG_FAILURE(Unable to support ESMTP) fi else SUPPORT_ESMTP=1 fi fi if test $SUPPORT_ESMTP = 1; then PKG_FEATURES="$PKG_FEATURES libesmtp" fi AC_SUBST(ESMTPLIBS) AM_CONDITIONAL(ENABLE_ESMTP, test "$SUPPORT_ESMTP" = "1") AC_DEFINE_UNQUOTED(ENABLE_ESMTP, $SUPPORT_ESMTP, Build in support for sending mail notifications with ESMTP) dnl ======================================================================== dnl GnuTLS dnl ======================================================================== AC_CHECK_HEADERS(gnutls/gnutls.h) AC_CHECK_HEADERS(security/pam_appl.h pam/pam_appl.h) dnl GNUTLS library: Attempt to determine by 'libgnutls-config' program. dnl If no 'libgnutls-config', try traditional autoconf means. AC_PATH_PROGS(LIBGNUTLS_CONFIG, libgnutls-config) if test -n "$LIBGNUTLS_CONFIG"; then AC_MSG_CHECKING(for gnutls header flags) GNUTLSHEAD="`$LIBGNUTLS_CONFIG --cflags`"; AC_MSG_RESULT($GNUTLSHEAD) AC_MSG_CHECKING(for gnutls library flags) GNUTLSLIBS="`$LIBGNUTLS_CONFIG --libs`"; AC_MSG_RESULT($GNUTLSLIBS) else AC_CHECK_LIB(gnutls, gnutls_init) fi AC_SUBST(GNUTLSHEAD) AC_SUBST(GNUTLSLIBS) dnl ======================================================================== dnl System Health dnl ======================================================================== dnl Check if servicelog development package is installed SERVICELOG=servicelog-1 SERVICELOG_EXISTS="no" AC_MSG_CHECKING(for $SERVICELOG packages) if $PKGCONFIG --exists $SERVICELOG then SERVICELOG_EXISTS="yes" fi AC_MSG_RESULT($SERVICELOG_EXISTS) AM_CONDITIONAL(BUILD_SERVICELOG, test "$SERVICELOG_EXISTS" = "yes") dnl Check if OpenIMPI packages and servicelog are installed OPENIPMI="OpenIPMI OpenIPMIposix" OPENIPMI_SERVICELOG_EXISTS="no" AC_MSG_CHECKING(for $SERVICELOG $OPENIPMI packages) if $PKGCONFIG --exists $OPENIPMI $SERVICELOG then OPENIPMI_SERICELOG_EXISTS="yes" fi AC_MSG_RESULT($OPENIPMI_SERICELOG_EXISTS) AM_CONDITIONAL(BUILD_OPENIPMI_SERICELOG, test "$OPENIPMI_SERICELOG_EXISTS" = "yes") dnl ======================================================================== dnl checks for library functions to replace them dnl dnl NoSuchFunctionName: dnl is a dummy function which no system supplies. It is here to make dnl the system compile semi-correctly on OpenBSD which doesn't know dnl how to create an empty archive dnl dnl scandir: Only on BSD. dnl System-V systems may have it, but hidden and/or deprecated. dnl A replacement function is supplied for it. dnl dnl setenv: is some bsdish function that should also be avoided (use dnl putenv instead) dnl On the other hand, putenv doesn't provide the right API for the dnl code and has memory leaks designed in (sigh...) Fortunately this dnl A replacement function is supplied for it. dnl dnl strerror: returns a string that corresponds to an errno. dnl A replacement function is supplied for it. dnl dnl unsetenv: is some bsdish function that should also be avoided (No dnl replacement) dnl A replacement function is supplied for it. dnl dnl strnlen: is a gnu function similar to strlen, but safer. dnl We wrote a tolearably-fast replacement function for it. dnl dnl strndup: is a gnu function similar to strdup, but safer. dnl We wrote a tolearably-fast replacement function for it. dnl dnl daemon: is a GNU function. The daemon() function is for programs wishing to dnl detach themselves from the controlling terminal and run in the dnl background as system daemon dnl A replacement function is supplied for it. AC_REPLACE_FUNCS(alphasort inet_pton NoSuchFunctionName scandir setenv strerror unsetenv strnlen strndup daemon strlcpy strlcat) dnl ======================================================================== dnl Compiler flags dnl ======================================================================== dnl Make sure that CFLAGS is not exported. If the user did dnl not have CFLAGS in their environment then this should have dnl no effect. However if CFLAGS was exported from the user's dnl environment, then the new CFLAGS will also be exported dnl to sub processes. CC_ERRORS="" CC_EXTRAS="" if export | fgrep " CFLAGS=" > /dev/null; then export -n CFLAGS || true # We don't want to bomb out if this fails fi if test "$GCC" != yes; then CFLAGS="$CFLAGS -g" enable_fatal_warnings=no else CFLAGS="$CFLAGS -ggdb3 -O0" # We had to eliminate -Wnested-externs because of libtool changes EXTRA_FLAGS="-fgnu89-inline -fstack-protector-all -Wall -Waggregate-return -Wbad-function-cast -Wcast-qual -Wcast-align -Wdeclaration-after-statement -Wendif-labels -Wfloat-equal -Wformat=2 -Wformat-security -Wformat-nonliteral -Winline -Wmissing-prototypes -Wmissing-declarations -Wnested-externs -Wno-long-long -Wno-strict-aliasing -Wpointer-arith -Wstrict-prototypes -Wunsigned-char -Wwrite-strings" # Additional warnings it might be nice to enable one day # -Wshadow # -Wunreachable-code for j in $EXTRA_FLAGS do if cc_supports_flag $j then CC_EXTRAS="$CC_EXTRAS $j" fi done dnl In lib/ais/Makefile.am there's a gcc option available as of v4.x GCC_MAJOR=`gcc -v 2>&1 | awk 'END{print $3}' | sed 's/[.].*//'` AM_CONDITIONAL(GCC_4, test "${GCC_MAJOR}" = 4) dnl System specific options case "$host_os" in *linux*|*bsd*) if test "${enable_fatal_warnings}" = "unknown"; then enable_fatal_warnings=yes fi ;; esac if test "x${enable_fatal_warnings}" != xno && cc_supports_flag -Werror ; then enable_fatal_warnings=yes else enable_fatal_warnings=no fi if test "x${enable_ansi}" != xno && cc_supports_flag -std=iso9899:199409 ; then AC_MSG_NOTICE(Enabling ANSI Compatibility) CC_EXTRAS="$CC_EXTRAS -ansi -D_GNU_SOURCE -DANSI_ONLY" fi AC_MSG_NOTICE(Activated additional gcc flags: ${CC_EXTRAS}) fi CFLAGS="$CFLAGS $CC_EXTRAS" NON_FATAL_CFLAGS="$CFLAGS" AC_SUBST(NON_FATAL_CFLAGS) dnl dnl We reset CFLAGS to include our warnings *after* all function dnl checking goes on, so that our warning flags don't keep the dnl AC_*FUNCS() calls above from working. In particular, -Werror will dnl *always* cause us troubles if we set it before here. dnl dnl if test "x${enable_fatal_warnings}" = xyes ; then AC_MSG_NOTICE(Enabling Fatal Warnings) CFLAGS="$CFLAGS -Werror" fi AC_SUBST(CFLAGS) dnl This is useful for use in Makefiles that need to remove one specific flag CFLAGS_COPY="$CFLAGS" AC_SUBST(CFLAGS_COPY) AC_SUBST(LIBADD_DL) dnl extra flags for dynamic linking libraries AC_SUBST(LIBADD_INTL) dnl extra flags for GNU gettext stuff... AC_SUBST(LOCALE) dnl Options for cleaning up the compiler output QUIET_LIBTOOL_OPTS="" QUIET_MAKE_OPTS="" if test "x${enable_quiet}" = "xyes"; then QUIET_LIBTOOL_OPTS="--quiet" QUIET_MAKE_OPTS="--quiet" fi AC_MSG_RESULT(Supress make details: ${enable_quiet}) dnl Put the above variables to use LIBTOOL="${LIBTOOL} --tag=CC \$(QUIET_LIBTOOL_OPTS)" MAKE="${MAKE} \$(QUIET_MAKE_OPTS)" AC_SUBST(CC) AC_SUBST(MAKE) AC_SUBST(LIBTOOL) AC_SUBST(QUIET_MAKE_OPTS) AC_SUBST(QUIET_LIBTOOL_OPTS) dnl The Makefiles and shell scripts we output AC_CONFIG_FILES(Makefile \ cts/Makefile \ cts/CTSvars.py \ cts/LSBDummy \ cib/Makefile \ crmd/Makefile \ pengine/Makefile \ pengine/regression.core.sh \ debian/Makefile \ doc/Makefile \ doc/cibadmin.8 \ doc/crm_resource.8 \ include/Makefile \ include/crm/Makefile \ include/crm/common/Makefile \ include/crm/pengine/Makefile \ replace/Makefile \ lib/Makefile \ lib/ais/Makefile \ lib/common/Makefile \ lib/cib/Makefile \ lib/pengine/Makefile \ lib/transition/Makefile \ lib/fencing/Makefile \ lib/plugins/Makefile \ lib/plugins/lrm/Makefile \ fencing/Makefile \ extra/Makefile \ extra/resources/Makefile \ tools/Makefile \ tools/haresources2cib.py \ tools/hb2openais.sh \ tools/crm_primitive.py \ tools/crm \ - tools/shell/Makefile \ - tools/shell/templates/Makefile \ - tools/shell/regression/Makefile \ - tools/shell/regression/regression.sh \ - tools/shell/regression/lrmregtest-lsb \ - tools/shell/regression/testcases/Makefile \ + shell/Makefile \ + shell/templates/Makefile \ + shell/regression/Makefile \ + shell/regression/regression.sh \ + shell/regression/lrmregtest-lsb \ + shell/regression/testcases/Makefile \ xml/Makefile \ xml/pacemaker.rng \ xml/resources.rng \ xml/constraints.rng \ xml/rule.rng \ xml/nvset.rng \ ) dnl Now process the entire list of files added by previous dnl calls to AC_CONFIG_FILES() AC_OUTPUT() dnl ***************** dnl Configure summary dnl ***************** AC_MSG_RESULT([]) AC_MSG_RESULT([$PACKAGE configuration:]) AC_MSG_RESULT([ Version = ${VERSION} (Build: $BUILD_VERSION)]) AC_MSG_RESULT([ Features =${PKG_FEATURES}]) AC_MSG_RESULT([]) AC_MSG_RESULT([ Prefix = ${prefix}]) AC_MSG_RESULT([ Executables = ${sbindir}]) AC_MSG_RESULT([ Man pages = ${mandir}]) AC_MSG_RESULT([ Libraries = ${libdir}]) AC_MSG_RESULT([ Header files = ${includedir}]) AC_MSG_RESULT([ Arch-independent files = ${datadir}]) AC_MSG_RESULT([ State information = ${localstatedir}]) AC_MSG_RESULT([ System configuration = ${sysconfdir}]) AC_MSG_RESULT([ AIS Plugins = ${LCRSODIR}]) AC_MSG_RESULT([]) AC_MSG_RESULT([ Use system LTDL = ${ac_cv_lib_ltdl_lt_dlopen}]) AC_MSG_RESULT([]) AC_MSG_RESULT([ HA group name = ${CRM_DAEMON_GROUP}]) AC_MSG_RESULT([ HA user name = ${CRM_DAEMON_USER}]) AC_MSG_RESULT([]) AC_MSG_RESULT([ CFLAGS = ${CFLAGS}]) AC_MSG_RESULT([ Libraries = ${LIBS}]) AC_MSG_RESULT([ Stack Libraries = ${CLUSTERLIBS}]) diff --git a/cts/CTStests.py b/cts/CTStests.py index 1de479b906..e4f6aac398 100644 --- a/cts/CTStests.py +++ b/cts/CTStests.py @@ -1,2398 +1,2415 @@ '''CTS: Cluster Testing System: Tests module There are a few things we want to do here: ''' __copyright__=''' Copyright (C) 2000, 2001 Alan Robertson Licensed under the GNU GPL. Add RecourceRecover testcase Zhao Kai ''' # # This program is free software; you can redistribute it and/or # modify it under the terms of the GNU General Public License # as published by the Free Software Foundation; either version 2 # of the License, or (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program; if not, write to the Free Software # Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. # # SPECIAL NOTE: # # Tests may NOT implement any cluster-manager-specific code in them. # EXTEND the ClusterManager object to provide the base capabilities # the test needs if you need to do something that the current CM classes # do not. Otherwise you screw up the whole point of the object structure # in CTS. # # Thank you. # import CTS import CTSaudits import time, os, re, types, string, tempfile, sys from CTSaudits import * from stat import * # List of all class objects for tests which we ought to # consider running. class AllTests: ''' A collection of tests which are run at random. ''' def __init__(self, scenario, cm, tests, Audits): self.CM = cm self.Env = cm.Env self.Scenario = scenario self.Tests = [] self.Audits = [] self.ns=CTS.NodeStatus(self.Env) self.Stats = {"success":0, "failure":0, "BadNews":0, "skipped":0} self.IndividualStats= {} for audit in Audits: if not issubclass(audit.__class__, ClusterAudit): raise ValueError("Init value must be a subclass of ClusterAudit") if audit.is_applicable(): self.Audits.append(audit) for test in tests: if not issubclass(test.__class__, CTSTest): raise ValueError("Init value must be a subclass of CTSTest") if test.is_applicable(): self.Tests.append(test) if not scenario.IsApplicable(): raise ValueError("Scenario not applicable in" " given Environment") def incr(self, name): '''Increment (or initialize) the value associated with the given name''' if not self.Stats.has_key(name): self.Stats[name]=0 self.Stats[name] = self.Stats[name]+1 def audit(self, BadNews, test): errcount=0 BadNewsDebug=0 #BadNews.debug=1 ignorelist = [] ignorelist.append(" CTS: ") ignorelist.append("BadNews:") ignorelist.extend(self.CM.errorstoignore()) if test: ignorelist.extend(test.errorstoignore()) while errcount < 1000: if BadNewsDebug: print "Looking for BadNews" match=BadNews.look(0) if match: if BadNewsDebug: print "BadNews found: "+match add_err = 1 for ignore in ignorelist: if add_err == 1 and re.search(ignore, match): if BadNewsDebug: print "Ignoring based on pattern: ("+ignore+")" add_err = 0 if add_err == 1: self.CM.log("BadNews: " + match) self.incr("BadNews") errcount=errcount+1 else: break else: answer = raw_input('Big problems. Continue? [nY]') if answer and answer == "n": self.CM.log("Shutting down.") self.CM.stopall() self.summarize() raise ValueError("Looks like we hit a BadNews jackpot!") for audit in self.Audits: if not audit(): self.CM.log("Audit " + audit.name() + " FAILED.") self.incr("auditfail") if test: test.incr("auditfail") def summarize(self): self.CM.log("****************") self.CM.log("Overall Results:" + repr(self.Stats)) self.CM.log("****************") stat_filter = { "calls":0, "failure":0, "skipped":0, "auditfail":0, } self.CM.log("Test Summary") for test in self.Tests: for key in stat_filter.keys(): stat_filter[key] = test.Stats[key] self.CM.log(("Test %s: "%test.name).ljust(25) + " %s"%repr(stat_filter)) self.CM.debug("Detailed Results") for test in self.Tests: self.CM.debug(("Test %s: "%test.name).ljust(25) + " %s"%repr(test.Stats)) self.CM.log("<<<<<<<<<<<<<<<< TESTS COMPLETED") def test_loop(self, BadNews, max): testcount=1 self.CM.log("Executing all tests once") for test in self.Tests: if self.run_test(BadNews, test, testcount): testcount += 1 return testcount def run_test(self, BadNews, test, testcount): nodechoice = self.Env.RandomNode() ret = 1 where = "" did_run = 0 self.CM.log(("Running test %s" % test.name).ljust(35) + (" (%s) " % nodechoice).ljust(15) +"["+ ("%d" % testcount).rjust(3) +"]") - starttime=test.set_starttime() + starttime = test.set_timer() if not test.setup(nodechoice): self.CM.log("Setup failed") ret = 0 elif not test.canrunnow(nodechoice): self.CM.log("Skipped") test.skipped() else: did_run = 1 ret = test(nodechoice) if not test.teardown(nodechoice): self.CM.log("Teardown failed") ret = 0 - test.log_mark("stop") stoptime=time.time() self.CM.oprofileSave(testcount) elapsed_time = stoptime - starttime - test_time = stoptime - test.starttime + test_time = stoptime - test.get_timer() if not test.has_key("min_time"): test["elapsed_time"] = elapsed_time test["min_time"] = test_time test["max_time"] = test_time else: test["elapsed_time"] = test["elapsed_time"] + elapsed_time if test_time < test["min_time"]: test["min_time"] = test_time if test_time > test["max_time"]: test["max_time"] = test_time if ret: self.incr("success") - self.CM.debug("Test %s runtime: %.2f" % (test.name, test_time)) + test.log_timer() else: self.incr("failure") self.CM.statall() did_run = 1 # Force the test count to be incrimented anyway so test extraction works self.audit(BadNews, test) return did_run def run(self, max=1): ( ''' Set up the given scenario, then run the selected tests at random for the selected number of iterations. ''') BadNews=CTS.LogWatcher(self.CM["LogFileName"], self.CM["BadRegexes"] , timeout=0) BadNews.setwatch() self.CM.ns.WaitForAllNodesToComeUp(self.CM.Env["nodes"]) self.CM.oprofileStop() self.CM.oprofileStart() if not self.CM.Env["DoBSC"]: audit = LogAudit(self.CM) if not audit(): self.CM.log("Audit " + audit.name() + " FAILED.") return (None, None) else: self.CM.log("Audit " + audit.name() + " passed.") audit = DiskAudit(self.CM) if not audit(): self.CM.log("Audit " + audit.name() + " FAILED.") return (None, None) else: self.CM.log("Audit " + audit.name() + " passed.") if not self.Scenario.SetUp(self.CM): return (None, None) self.CM.oprofileSave(0) time.sleep(30) # This makes sure everything is stabilized before starting... self.audit(BadNews, None) testcount = self.test_loop(BadNews, max) self.Scenario.TearDown(self.CM) self.CM.oprofileSave(testcount) self.CM.oprofileStop() self.audit(BadNews, None) for test in self.Tests: self.IndividualStats[test.name] = test.Stats return self.Stats, self.IndividualStats class RandomTests(AllTests): def test_loop(self, BadNews, max): testcount=1 self.CM.log("Executing tests at random") while testcount <= max: test = self.Env.RandomGen.choice(self.Tests) if self.run_test(BadNews, test, testcount): testcount += 1 return testcount class BenchTests(AllTests): ''' Nothing (yet) here. ''' AllTestClasses = [ ] class CTSTest: ''' A Cluster test. We implement the basic set of properties and behaviors for a generic cluster test. Cluster tests track their own statistics. We keep each of the kinds of counts we track as separate {name,value} pairs. ''' def __init__(self, cm): #self.name="the unnamed test" self.Stats = {"calls":0 , "success":0 , "failure":0 , "skipped":0 , "auditfail":0} # if not issubclass(cm.__class__, ClusterManager): # raise ValueError("Must be a ClusterManager object") self.CM = cm self.Audits = [] self.timeout=120 - self.starttime=0 self.passed = 1 self.is_loop = 0 self.is_unsafe = 0 self.is_experimental = 0 self.is_valgrind = 0 self.benchmark = 0 # which tests to benchmark + self.timer = {} # timers def has_key(self, key): return self.Stats.has_key(key) def __setitem__(self, key, value): self.Stats[key] = value def __getitem__(self, key): return self.Stats[key] def log_mark(self, msg): - self.CM.debug("MARK: test %s %s %d" % (self.name,msg,time.time())) - return - - def set_starttime(self): - self.starttime=time.time() - self.log_mark("start") - return self.starttime + self.CM.debug("MARK: test %s %s %d" % (self.name,msg,time.time())) + return + + def get_timer(self,key = "test"): + try: return self.timer[key] + except: return 0 + + def set_timer(self,key = "test"): + self.timer[key] = time.time() + return self.timer[key] + + def log_timer(self,key = "test"): + elapsed = 0 + if key in self.timer: + elapsed = time.time() - self.timer[key] + s = key == "test" and self.name or "%s:%s" %(self.name,key) + self.CM.debug("%s runtime: %.2f" % (s, elapsed)) + del self.timer[key] + return elapsed def incr(self, name): '''Increment (or initialize) the value associated with the given name''' if not self.Stats.has_key(name): self.Stats[name]=0 self.Stats[name] = self.Stats[name]+1 # Reset the test passed boolean if name == "calls": self.passed = 1 def failure(self, reason="none"): '''Increment the failure count''' self.passed = 0 self.incr("failure") self.CM.log(("Test %s" % self.name).ljust(35) +" FAILED: %s" % reason) return None def success(self): '''Increment the success count''' self.incr("success") return 1 def skipped(self): '''Increment the skipped count''' self.incr("skipped") return 1 def __call__(self, node): '''Perform the given test''' raise ValueError("Abstract Class member (__call__)") self.incr("calls") return self.failure() def audit(self): passed = 1 if len(self.Audits) > 0: for audit in self.Audits: if not audit(): self.CM.log("Internal %s Audit %s FAILED." % (self.name, audit.name())) self.incr("auditfail") passed = 0 return passed def setup(self, node): '''Setup the given test''' return self.success() def teardown(self, node): '''Tear down the given test''' return self.success() def local_badnews(self, prefix, watch, local_ignore=[]): errcount = 0 if not prefix: prefix = "LocalBadNews:" ignorelist = [] ignorelist.append(" CTS: ") ignorelist.append(prefix) ignorelist.extend(local_ignore) while errcount < 100: match=watch.look(0) if match: add_err = 1 for ignore in ignorelist: if add_err == 1 and re.search(ignore, match): add_err = 0 if add_err == 1: self.CM.log(prefix + " " + match) errcount=errcount+1 else: break else: self.CM.log("Too many errors!") return errcount def is_applicable(self): return self.is_applicable_common() def is_applicable_common(self): '''Return TRUE if we are applicable in the current test configuration''' #raise ValueError("Abstract Class member (is_applicable)") if self.is_loop and not self.CM.Env["loop-tests"]: return 0 elif self.is_unsafe and not self.CM.Env["unsafe-tests"]: return 0 elif self.is_valgrind and not self.CM.Env["valgrind-tests"]: return 0 elif self.is_experimental and not self.CM.Env["experimental-tests"]: return 0 return 1 def find_ocfs2_resources(self, node): self.r_o2cb = None self.r_ocfs2 = [] (rc, lines) = self.CM.rsh(node, "crm_resource -c", None) for line in lines: if re.search("^Resource", line): r = AuditResource(self.CM, line) if r.rtype == "o2cb" and r.parent != "NA": self.CM.debug("Found o2cb: %s" % self.r_o2cb) self.r_o2cb = r.parent if re.search("^Constraint", line): c = AuditConstraint(self.CM, line) if c.type == "rsc_colocation" and c.target == self.r_o2cb: self.r_ocfs2.append(c.rsc) self.CM.debug("Found ocfs2 filesystems: %s" % repr(self.r_ocfs2)) return len(self.r_ocfs2) def canrunnow(self, node): '''Return TRUE if we can meaningfully run right now''' return 1 def errorstoignore(self): '''Return list of errors which are 'normal' and should be ignored''' return [] ################################################################### class StopTest(CTSTest): ################################################################### '''Stop (deactivate) the cluster manager on a node''' def __init__(self, cm): CTSTest.__init__(self, cm) self.name="Stop" def __call__(self, node): '''Perform the 'stop' test. ''' self.incr("calls") if self.CM.ShouldBeStatus[node] != "up": return self.skipped() patterns = [] # Technically we should always be able to notice ourselves stopping patterns.append(self.CM["Pat:We_stopped"] % node) #if self.CM.Env["use_logd"]: # patterns.append(self.CM["Pat:Logd_stopped"] % node) # Any active node needs to notice this one left # NOTE: This wont work if we have multiple partitions for other in self.CM.Env["nodes"]: if self.CM.ShouldBeStatus[other] == "up" and other != node: patterns.append(self.CM["Pat:They_stopped"] %(other, node)) #self.debug("Checking %s will notice %s left"%(other, node)) watch = CTS.LogWatcher( self.CM["LogFileName"], patterns, self.CM["DeadTime"]) watch.setwatch() if node == self.CM.OurNode: self.incr("us") else: if self.CM.upcount() <= 1: self.incr("all") else: self.incr("them") self.CM.StopaCM(node) watch_result = watch.lookforall() failreason=None UnmatchedList = "||" if watch.unmatched: (rc, output) = self.CM.rsh(node, "/bin/ps axf", None) for line in output: self.CM.debug(line) for regex in watch.unmatched: self.CM.log ("ERROR: Shutdown pattern not found: %s" % (regex)) UnmatchedList += regex + "||"; failreason="Missing shutdown pattern" self.CM.cluster_stable(self.CM["DeadTime"]) if not watch.unmatched or self.CM.upcount() == 0: return self.success() if len(watch.unmatched) >= self.CM.upcount(): return self.failure("no match against (%s)" % UnmatchedList) if failreason == None: return self.success() else: return self.failure(failreason) # # We don't register StopTest because it's better when called by # another test... # ################################################################### class StartTest(CTSTest): ################################################################### '''Start (activate) the cluster manager on a node''' def __init__(self, cm, debug=None): CTSTest.__init__(self,cm) self.name="start" self.debug = debug def __call__(self, node): '''Perform the 'start' test. ''' self.incr("calls") if self.CM.upcount() == 0: self.incr("us") else: self.incr("them") if self.CM.ShouldBeStatus[node] != "down": return self.skipped() elif self.CM.StartaCM(node): return self.success() else: return self.failure("Startup %s on node %s failed" %(self.CM["Name"], node)) # # We don't register StartTest because it's better when called by # another test... # ################################################################### class FlipTest(CTSTest): ################################################################### '''If it's running, stop it. If it's stopped start it. Overthrow the status quo... ''' def __init__(self, cm): CTSTest.__init__(self,cm) self.name="Flip" self.start = StartTest(cm) self.stop = StopTest(cm) def __call__(self, node): '''Perform the 'Flip' test. ''' self.incr("calls") if self.CM.ShouldBeStatus[node] == "up": self.incr("stopped") ret = self.stop(node) type="up->down" # Give the cluster time to recognize it's gone... time.sleep(self.CM["StableTime"]) elif self.CM.ShouldBeStatus[node] == "down": self.incr("started") ret = self.start(node) type="down->up" else: return self.skipped() self.incr(type) if ret: return self.success() else: return self.failure("%s failure" % type) # Register FlipTest as a good test to run AllTestClasses.append(FlipTest) ################################################################### class RestartTest(CTSTest): ################################################################### '''Stop and restart a node''' def __init__(self, cm): CTSTest.__init__(self,cm) self.name="Restart" self.start = StartTest(cm) self.stop = StopTest(cm) self.benchmark = 1 def __call__(self, node): '''Perform the 'restart' test. ''' self.incr("calls") self.incr("node:" + node) ret1 = 1 if self.CM.StataCM(node): self.incr("WasStopped") if not self.start(node): return self.failure("start (setup) failure: "+node) - self.set_starttime() + self.set_timer() if not self.stop(node): return self.failure("stop failure: "+node) if not self.start(node): return self.failure("start failure: "+node) return self.success() # Register RestartTest as a good test to run AllTestClasses.append(RestartTest) ################################################################### class StonithdTest(CTSTest): ################################################################### def __init__(self, cm): CTSTest.__init__(self, cm) self.name="Stonithd" self.startall = SimulStartLite(cm) self.benchmark = 1 def __call__(self, node): self.incr("calls") if len(self.CM.Env["nodes"]) < 2: return self.skipped() ret = self.startall(None) if not ret: return self.failure("Setup failed") watchpats = [] watchpats.append("Forcing node %s to be terminated" % node) watchpats.append("Scheduling Node %s for STONITH" % node) watchpats.append("Executing .* fencing operation") watchpats.append("stonith-ng:.*Operation .* for host '%s' with device .* returned: 0" % node) if not self.CM.is_node_dc(node): # Won't be found if the DC is shot (and there's no equivalent message from stonithd) watchpats.append("tengine_stonith_callback: .*: OK ") # TODO else: look for the notification on a peer once implimented if self.CM.Env["at-boot"] == 0: self.CM.debug("Expecting %s to stay down" % node) self.CM.ShouldBeStatus[node]="down" else: self.CM.debug("Expecting %s to come up again %d" % (node, self.CM.Env["at-boot"])) watchpats.append("%s crmd: .* S_STARTING -> S_PENDING" % node) watchpats.append("%s crmd: .* S_PENDING -> S_NOT_DC" % node) watch = CTS.LogWatcher(self.CM["LogFileName"], watchpats, self.CM["DeadTime"] + self.CM["StableTime"] + self.CM["StartTime"]) watch.setwatch() self.CM.rsh(node, "crm_attribute --node %s --type status --attr-name terminate --attr-value true" % node) + self.set_timer("fence") matched = watch.lookforall() + self.log_timer("fence") + self.set_timer("reform") if matched: self.CM.debug("Found: "+ repr(matched)) else: self.CM.log("Patterns not found: " + repr(watch.unmatched)) self.CM.debug("Waiting for the cluster to recover") self.CM.cluster_stable() self.CM.debug("Waiting STONITHd node to come back up") self.CM.ns.WaitForAllNodesToComeUp(self.CM.Env["nodes"], 600) self.CM.debug("Waiting for the cluster to re-stabilize with all nodes") is_stable = self.CM.cluster_stable(self.CM["StartTime"]) if not matched: return self.failure("Didn't find all expected patterns") elif not is_stable: return self.failure("Cluster did not become stable") + self.log_timer("reform") return self.success() def errorstoignore(self): return [ "Executing .* fencing operation" ] def is_applicable(self): if not self.is_applicable_common(): return 0 if self.CM.Env.has_key("DoStonith"): return self.CM.Env["DoStonith"] return 1 AllTestClasses.append(StonithdTest) ################################################################### class StartOnebyOne(CTSTest): ################################################################### '''Start all the nodes ~ one by one''' def __init__(self, cm): CTSTest.__init__(self,cm) self.name="StartOnebyOne" self.stopall = SimulStopLite(cm) self.start = StartTest(cm) self.ns=CTS.NodeStatus(cm.Env) def __call__(self, dummy): '''Perform the 'StartOnebyOne' test. ''' self.incr("calls") # We ignore the "node" parameter... # Shut down all the nodes... ret = self.stopall(None) if not ret: return self.failure("Test setup failed") failed=[] - self.set_starttime() + self.set_timer() for node in self.CM.Env["nodes"]: if not self.start(node): failed.append(node) if len(failed) > 0: return self.failure("Some node failed to start: " + repr(failed)) return self.success() # Register StartOnebyOne as a good test to run AllTestClasses.append(StartOnebyOne) ################################################################### class SimulStart(CTSTest): ################################################################### '''Start all the nodes ~ simultaneously''' def __init__(self, cm): CTSTest.__init__(self,cm) self.name="SimulStart" self.stopall = SimulStopLite(cm) self.startall = SimulStartLite(cm) def __call__(self, dummy): '''Perform the 'SimulStart' test. ''' self.incr("calls") # We ignore the "node" parameter... # Shut down all the nodes... ret = self.stopall(None) if not ret: return self.failure("Setup failed") self.CM.clear_all_caches() if not self.startall(None): return self.failure("Startall failed") return self.success() # Register SimulStart as a good test to run AllTestClasses.append(SimulStart) ################################################################### class SimulStop(CTSTest): ################################################################### '''Stop all the nodes ~ simultaneously''' def __init__(self, cm): CTSTest.__init__(self,cm) self.name="SimulStop" self.startall = SimulStartLite(cm) self.stopall = SimulStopLite(cm) def __call__(self, dummy): '''Perform the 'SimulStop' test. ''' self.incr("calls") # We ignore the "node" parameter... # Start up all the nodes... ret = self.startall(None) if not ret: return self.failure("Setup failed") if not self.stopall(None): return self.failure("Stopall failed") return self.success() # Register SimulStop as a good test to run AllTestClasses.append(SimulStop) ################################################################### class StopOnebyOne(CTSTest): ################################################################### '''Stop all the nodes in order''' def __init__(self, cm): CTSTest.__init__(self,cm) self.name="StopOnebyOne" self.startall = SimulStartLite(cm) self.stop = StopTest(cm) def __call__(self, dummy): '''Perform the 'StopOnebyOne' test. ''' self.incr("calls") # We ignore the "node" parameter... # Start up all the nodes... ret = self.startall(None) if not ret: return self.failure("Setup failed") failed=[] - self.set_starttime() + self.set_timer() for node in self.CM.Env["nodes"]: if not self.stop(node): failed.append(node) if len(failed) > 0: return self.failure("Some node failed to stop: " + repr(failed)) self.CM.clear_all_caches() return self.success() # Register StopOnebyOne as a good test to run AllTestClasses.append(StopOnebyOne) ################################################################### class RestartOnebyOne(CTSTest): ################################################################### '''Restart all the nodes in order''' def __init__(self, cm): CTSTest.__init__(self,cm) self.name="RestartOnebyOne" self.startall = SimulStartLite(cm) def __call__(self, dummy): '''Perform the 'RestartOnebyOne' test. ''' self.incr("calls") # We ignore the "node" parameter... # Start up all the nodes... ret = self.startall(None) if not ret: return self.failure("Setup failed") did_fail=[] - self.set_starttime() + self.set_timer() self.restart = RestartTest(self.CM) for node in self.CM.Env["nodes"]: if not self.restart(node): did_fail.append(node) if did_fail: return self.failure("Could not restart %d nodes: %s" %(len(did_fail), repr(did_fail))) return self.success() # Register StopOnebyOne as a good test to run AllTestClasses.append(RestartOnebyOne) ################################################################### class PartialStart(CTSTest): ################################################################### '''Start a node - but tell it to stop before it finishes starting up''' def __init__(self, cm): CTSTest.__init__(self,cm) self.name="PartialStart" self.startall = SimulStartLite(cm) self.stopall = SimulStopLite(cm) #self.is_unsafe = 1 def __call__(self, node): '''Perform the 'PartialStart' test. ''' self.incr("calls") ret = self.stopall(None) if not ret: return self.failure("Setup failed") # FIXME! This should use the CM class to get the pattern # then it would be applicable in general watchpats = [] watchpats.append("Starting crmd") watch = CTS.LogWatcher(self.CM["LogFileName"], watchpats, timeout=self.CM["DeadTime"]+10) watch.setwatch() self.CM.StartaCMnoBlock(node) ret = watch.lookforall() if not ret: self.CM.log("Patterns not found: " + repr(watch.unmatched)) return self.failure("Setup of %s failed" % node) ret = self.stopall(None) if not ret: return self.failure("%s did not stop in time" % node) return self.success() # Register StopOnebyOne as a good test to run AllTestClasses.append(PartialStart) ####################################################################### class StandbyTest(CTSTest): ####################################################################### def __init__(self, cm): CTSTest.__init__(self,cm) self.name="Standby" self.benchmark = 1 self.start = StartTest(cm) self.startall = SimulStartLite(cm) # make sure the node is active # set the node to standby mode # check resources, none resource should be running on the node # set the node to active mode # check resouces, resources should have been migrated back (SHOULD THEY?) def __call__(self, node): self.incr("calls") ret=self.startall(None) if not ret: return self.failure("Start all nodes failed") self.CM.debug("Make sure node %s is active" % node) if self.CM.StandbyStatus(node) != "off": if not self.CM.SetStandbyMode(node, "off"): return self.failure("can't set node %s to active mode" % node) self.CM.cluster_stable() status = self.CM.StandbyStatus(node) if status != "off": return self.failure("standby status of %s is [%s] but we expect [off]" % (node, status)) self.CM.debug("Getting resources running on node %s" % node) rsc_on_node = self.CM.active_resources(node) self.CM.debug("Setting node %s to standby mode" % node) if not self.CM.SetStandbyMode(node, "on"): return self.failure("can't set node %s to standby mode" % node) - self.log_mark("standby:on") + self.set_timer("on") time.sleep(1) # Allow time for the update to be applied and cause something self.CM.cluster_stable() status = self.CM.StandbyStatus(node) if status != "on": return self.failure("standby status of %s is [%s] but we expect [on]" % (node, status)) - self.log_mark("standby:on-idle") + self.log_timer("on") self.CM.debug("Checking resources") bad_run = self.CM.active_resources(node) if len(bad_run) > 0: rc = self.failure("%s set to standby, %s is still running on it" % (node, repr(bad_run))) self.CM.debug("Setting node %s to active mode" % node) self.CM.SetStandbyMode(node, "off") return rc self.CM.debug("Setting node %s to active mode" % node) if not self.CM.SetStandbyMode(node, "off"): return self.failure("can't set node %s to active mode" % node) - self.log_mark("standby:off") + self.set_timer("off") self.CM.cluster_stable() status = self.CM.StandbyStatus(node) if status != "off": return self.failure("standby status of %s is [%s] but we expect [off]" % (node, status)) - self.log_mark("standby:off-idle") + self.log_timer("off") return self.success() AllTestClasses.append(StandbyTest) ####################################################################### class ValgrindTest(CTSTest): ####################################################################### '''Check for memory leaks''' def __init__(self, cm): CTSTest.__init__(self,cm) self.name="Valgrind" self.stopall = SimulStopLite(cm) self.startall = SimulStartLite(cm) self.is_valgrind = 1 self.is_loop = 1 def setup(self, node): self.incr("calls") ret=self.stopall(None) if not ret: return self.failure("Stop all nodes failed") # Enable valgrind self.logPat = "/tmp/%s-*.valgrind" % self.name self.CM.Env["valgrind-prefix"] = self.name self.CM.rsh(node, "rm -f %s" % self.logPat, None) ret=self.startall(None) if not ret: return self.failure("Start all nodes failed") for node in self.CM.Env["nodes"]: (rc, output) = self.CM.rsh(node, "ps u --ppid `pidofproc aisexec`", None) for line in output: self.CM.debug(line) return self.success() def teardown(self, node): # Disable valgrind self.CM.Env["valgrind-prefix"] = None # Return all nodes to normal ret=self.stopall(None) if not ret: return self.failure("Stop all nodes failed") return self.success() def find_leaks(self): # Check for leaks leaked = [] self.stop = StopTest(self.CM) for node in self.CM.Env["nodes"]: (rc, ps_out) = self.CM.rsh(node, "ps u --ppid `pidofproc aisexec`", None) rc = self.stop(node) if not rc: self.failure("Couldn't shut down %s" % node) rc = self.CM.rsh(node, "grep -e indirectly.*lost:.*[1-9] -e definitely.*lost:.*[1-9] -e ERROR.*SUMMARY:.*[1-9].*errors %s" % self.logPat, 0) if rc != 1: leaked.append(node) self.failure("Valgrind errors detected on %s" % node) for line in ps_out: self.CM.log(line) (rc, output) = self.CM.rsh(node, "grep -e lost: -e SUMMARY: %s" % self.logPat, None) for line in output: self.CM.log(line) (rc, output) = self.CM.rsh(node, "cat %s" % self.logPat, None) for line in output: self.CM.debug(line) self.CM.rsh(node, "rm -f %s" % self.logPat, None) return leaked def __call__(self, node): leaked = self.find_leaks() if len(leaked) > 0: return self.failure("Nodes %s leaked" % repr(leaked)) return self.success() def errorstoignore(self): '''Return list of errors which should be ignored''' return [ """cib:.*readCibXmlFile:""", """HA_VALGRIND_ENABLED""" ] ####################################################################### class StandbyLoopTest(ValgrindTest): ####################################################################### '''Check for memory leaks by putting a node in and out of standby for an hour''' def __init__(self, cm): ValgrindTest.__init__(self,cm) self.name="StandbyLoop" def __call__(self, node): lpc = 0 delay = 2 failed = 0 done=time.time() + self.CM.Env["loop-minutes"]*60 while time.time() <= done and not failed: lpc = lpc + 1 time.sleep(delay) if not self.CM.SetStandbyMode(node, "on"): self.failure("can't set node %s to standby mode" % node) failed = lpc time.sleep(delay) if not self.CM.SetStandbyMode(node, "off"): self.failure("can't set node %s to active mode" % node) failed = lpc leaked = self.find_leaks() if failed: return self.failure("Iteration %d failed" % failed) elif len(leaked) > 0: return self.failure("Nodes %s leaked" % repr(leaked)) return self.success() AllTestClasses.append(StandbyLoopTest) ############################################################################## class BandwidthTest(CTSTest): ############################################################################## # Tests should not be cluster-manager-specific # If you need to find out cluster manager configuration to do this, then # it should be added to the generic cluster manager API. '''Test the bandwidth which heartbeat uses''' def __init__(self, cm): CTSTest.__init__(self, cm) self.name = "Bandwidth" self.start = StartTest(cm) self.__setitem__("min",0) self.__setitem__("max",0) self.__setitem__("totalbandwidth",0) self.tempfile = tempfile.mktemp(".cts") self.startall = SimulStartLite(cm) def __call__(self, node): '''Perform the Bandwidth test''' self.incr("calls") if self.CM.upcount()<1: return self.skipped() Path = self.CM.InternalCommConfig() if "ip" not in Path["mediatype"]: return self.skipped() port = Path["port"][0] port = int(port) ret = self.startall(None) if not ret: return self.failure("Test setup failed") time.sleep(5) # We get extra messages right after startup. fstmpfile = "/var/run/band_estimate" dumpcmd = "tcpdump -p -n -c 102 -i any udp port %d > %s 2>&1" \ % (port, fstmpfile) rc = self.CM.rsh(node, dumpcmd) if rc == 0: farfile = "root@%s:%s" % (node, fstmpfile) self.CM.rsh.cp(farfile, self.tempfile) Bandwidth = self.countbandwidth(self.tempfile) if not Bandwidth: self.CM.log("Could not compute bandwidth.") return self.success() intband = int(Bandwidth + 0.5) self.CM.log("...bandwidth: %d bits/sec" % intband) self.Stats["totalbandwidth"] = self.Stats["totalbandwidth"] + Bandwidth if self.Stats["min"] == 0: self.Stats["min"] = Bandwidth if Bandwidth > self.Stats["max"]: self.Stats["max"] = Bandwidth if Bandwidth < self.Stats["min"]: self.Stats["min"] = Bandwidth self.CM.rsh(node, "rm -f %s" % fstmpfile) os.unlink(self.tempfile) return self.success() else: return self.failure("no response from tcpdump command [%d]!" % rc) def countbandwidth(self, file): fp = open(file, "r") fp.seek(0) count = 0 sum = 0 while 1: line = fp.readline() if not line: return None if re.search("udp",line) or re.search("UDP,", line): count=count+1 linesplit = string.split(line," ") for j in range(len(linesplit)-1): if linesplit[j]=="udp": break if linesplit[j]=="length:": break try: sum = sum + int(linesplit[j+1]) except ValueError: self.CM.log("Invalid tcpdump line: %s" % line) return None T1 = linesplit[0] timesplit = string.split(T1,":") time2split = string.split(timesplit[2],".") time1 = (long(timesplit[0])*60+long(timesplit[1]))*60+long(time2split[0])+long(time2split[1])*0.000001 break while count < 100: line = fp.readline() if not line: return None if re.search("udp",line) or re.search("UDP,", line): count = count+1 linessplit = string.split(line," ") for j in range(len(linessplit)-1): if linessplit[j] =="udp": break if linesplit[j]=="length:": break try: sum=int(linessplit[j+1])+sum except ValueError: self.CM.log("Invalid tcpdump line: %s" % line) return None T2 = linessplit[0] timesplit = string.split(T2,":") time2split = string.split(timesplit[2],".") time2 = (long(timesplit[0])*60+long(timesplit[1]))*60+long(time2split[0])+long(time2split[1])*0.000001 time = time2-time1 if (time <= 0): return 0 return (sum*8)/time def is_applicable(self): '''BandwidthTest never applicable''' return 0 AllTestClasses.append(BandwidthTest) ################################################################### class ResourceRecover(CTSTest): ################################################################### def __init__(self, cm): CTSTest.__init__(self,cm) self.name="ResourceRecover" self.start = StartTest(cm) self.startall = SimulStartLite(cm) self.max=30 self.rid=None #self.is_unsafe = 1 self.benchmark = 1 # these are the values used for the new LRM API call self.action = "asyncmon" self.interval = 0 def __call__(self, node): '''Perform the 'ResourceRecover' test. ''' self.incr("calls") ret = self.startall(None) if not ret: return self.failure("Setup failed") resourcelist = self.CM.active_resources(node) # if there are no resourcelist, return directly if len(resourcelist)==0: self.CM.log("No active resources on %s" % node) return self.skipped() self.rid = self.CM.Env.RandomGen.choice(resourcelist) rsc = None (rc, lines) = self.CM.rsh(node, "crm_resource -c", None) for line in lines: if re.search("^Resource", line): tmp = AuditResource(self.CM, line) if tmp.id == self.rid: rsc = tmp # Handle anonymous clones that get renamed self.rid = rsc.clone_id break if not rsc: return self.failure("Could not find %s in the resource list" % self.rid) self.CM.debug("Shooting %s aka. %s" % (rsc.clone_id, rsc.id)) pats = [] pats.append("Updating failcount for %s on .* after .* %s" % (self.rid, self.action)) if rsc.managed(): pats.append("crmd:.* Performing .* op=%s_stop_0" % self.rid) if rsc.unique(): pats.append("crmd:.* Performing .* op=%s_start_0" % self.rid) pats.append("crmd:.* LRM operation %s_start_0.*confirmed.*ok" % self.rid) else: # Anonymous clones may get restarted with a different clone number pats.append("crmd:.* Performing .* op=.*_start_0") pats.append("crmd:.* LRM operation .*_start_0.*confirmed.*ok") watch = CTS.LogWatcher(self.CM["LogFileName"], pats, timeout=60) watch.setwatch() self.CM.rsh(node, "crm_resource -F -r %s -H %s &>/dev/null" % (self.rid, node)) + self.set_timer("recover") watch.lookforall() + self.log_timer("recover") self.CM.cluster_stable() recovered=self.CM.ResourceLocation(self.rid) if watch.unmatched: return self.failure("Patterns not found: %s" % repr(watch.unmatched)) elif rsc.unique() and len(recovered) > 1: return self.failure("%s is now active on more than one node: %s"%(self.rid, repr(recovered))) elif len(recovered) > 0: self.CM.debug("%s is running on: %s" %(self.rid, repr(recovered))) elif rsc.managed(): return self.failure("%s was not recovered and is inactive" % self.rid) return self.success() def errorstoignore(self): '''Return list of errors which should be ignored''' return [ """Updating failcount for %s""" % self.rid, """Unknown operation: fail""", """ERROR: sending stonithRA op to stonithd failed.""", """ERROR: process_lrm_event: LRM operation %s_%s_%d""" % (self.rid, self.action, self.interval), """ERROR: process_graph_event: Action %s_%s_%d .* initiated outside of a transition""" % (self.rid, self.action, self.interval), ] AllTestClasses.append(ResourceRecover) ################################################################### class ComponentFail(CTSTest): ################################################################### def __init__(self, cm): CTSTest.__init__(self,cm) self.name="ComponentFail" self.startall = SimulStartLite(cm) self.complist = cm.Components() self.patterns = [] self.okerrpatterns = [] self.is_unsafe = 1 def __call__(self, node): '''Perform the 'ComponentFail' test. ''' self.incr("calls") self.patterns = [] self.okerrpatterns = [] # start all nodes ret = self.startall(None) if not ret: return self.failure("Setup failed") if not self.CM.cluster_stable(self.CM["StableTime"]): return self.failure("Setup failed - unstable") node_is_dc = self.CM.is_node_dc(node, None) # select a component to kill chosen = self.CM.Env.RandomGen.choice(self.complist) while chosen.dc_only == 1 and node_is_dc == 0: chosen = self.CM.Env.RandomGen.choice(self.complist) self.CM.debug("...component %s (dc=%d,boot=%d)" % (chosen.name, node_is_dc,chosen.triggersreboot)) self.incr(chosen.name) if chosen.name != "aisexec": if self.CM["Name"] != "crm-lha" or chosen.name != "pengine": self.patterns.append(self.CM["Pat:ChildKilled"] %(node, chosen.name)) self.patterns.append(self.CM["Pat:ChildRespawn"] %(node, chosen.name)) self.patterns.extend(chosen.pats) if node_is_dc: self.patterns.extend(chosen.dc_pats) # In an ideal world, this next stuff should be in the "chosen" object as a member function if self.CM["Name"] == "crm-lha" and chosen.triggersreboot: # Make sure the node goes down and then comes back up if it should reboot... for other in self.CM.Env["nodes"]: if other != node: self.patterns.append(self.CM["Pat:They_stopped"] %(other, node)) self.patterns.append(self.CM["Pat:Slave_started"] % node) self.patterns.append(self.CM["Pat:Local_started"] % node) if chosen.dc_only: # Sometimes these will be in the log, and sometimes they won't... self.okerrpatterns.append("%s crmd:.*Process %s:.* exited" %(node, chosen.name)) self.okerrpatterns.append("%s crmd:.*I_ERROR.*crmdManagedChildDied" %node) self.okerrpatterns.append("%s crmd:.*The %s subsystem terminated unexpectedly" %(node, chosen.name)) self.okerrpatterns.append("ERROR: Client .* exited with return code") else: # Sometimes this won't be in the log... self.okerrpatterns.append(self.CM["Pat:ChildKilled"] %(node, chosen.name)) self.okerrpatterns.append(self.CM["Pat:ChildRespawn"] %(node, chosen.name)) self.okerrpatterns.append(self.CM["Pat:ChildExit"]) # supply a copy so self.patterns doesnt end up empty tmpPats = [] tmpPats.extend(self.patterns) self.patterns.extend(chosen.badnews_ignore) # Look for STONITH ops, depending on Env["at-boot"] we might need to change the nodes status stonithPats = [] stonithPats.append("stonith-ng:.*Operation .* for host '%s' with device .* returned: 0" % node) stonith = CTS.LogWatcher(self.CM["LogFileName"], stonithPats, 0) stonith.setwatch() # set the watch for stable watch = CTS.LogWatcher( self.CM["LogFileName"], tmpPats, self.CM["DeadTime"] + self.CM["StableTime"] + self.CM["StartTime"]) watch.setwatch() # kill the component chosen.kill(node) # check to see Heartbeat noticed matched = watch.lookforall(allow_multiple_matches=1) if matched: self.CM.debug("Found: "+ repr(matched)) else: self.CM.log("Patterns not found: " + repr(watch.unmatched)) if self.CM.Env["at-boot"] == 0: self.CM.debug("Checking if %s was shot" % node) shot = stonith.look(60) if shot: self.CM.debug("Found: "+ repr(shot)) self.CM.ShouldBeStatus[node]="down" self.CM.debug("Waiting for the cluster to recover") self.CM.cluster_stable() self.CM.debug("Waiting for any STONITHd node to come back up") self.CM.ns.WaitForAllNodesToComeUp(self.CM.Env["nodes"], 600) self.CM.debug("Waiting for the cluster to re-stabilize with all nodes") is_stable = self.CM.cluster_stable(self.CM["StartTime"]) if not matched: return self.failure("Didn't find all expected patterns") elif not is_stable: return self.failure("Cluster did not become stable") return self.success() def errorstoignore(self): '''Return list of errors which should be ignored''' # Note that okerrpatterns refers to the last time we ran this test # The good news is that this works fine for us... self.okerrpatterns.extend(self.patterns) return self.okerrpatterns AllTestClasses.append(ComponentFail) #################################################################### class SplitBrainTest(CTSTest): #################################################################### '''It is used to test split-brain. when the path between the two nodes break check the two nodes both take over the resource''' def __init__(self,cm): CTSTest.__init__(self,cm) self.name = "SplitBrain" self.start = StartTest(cm) self.startall = SimulStartLite(cm) self.is_experimental = 1 def isolate_partition(self, partition): other_nodes = [] other_nodes.extend(self.CM.Env["nodes"]) for node in partition: try: other_nodes.remove(node) except ValueError: self.CM.log("Node "+node+" not in " + repr(self.CM.Env["nodes"]) + " from " +repr(partition)) if len(other_nodes) == 0: return 1 self.CM.debug("Creating partition: " + repr(partition)) self.CM.debug("Everyone else: " + repr(other_nodes)) for node in partition: if not self.CM.isolate_node(node, other_nodes): self.CM.log("Could not isolate %s" % node) return 0 return 1 def heal_partition(self, partition): other_nodes = [] other_nodes.extend(self.CM.Env["nodes"]) for node in partition: try: other_nodes.remove(node) except ValueError: self.CM.log("Node "+node+" not in " + repr(self.CM.Env["nodes"])) if len(other_nodes) == 0: return 1 self.CM.debug("Healing partition: " + repr(partition)) self.CM.debug("Everyone else: " + repr(other_nodes)) for node in partition: self.CM.unisolate_node(node, other_nodes) def __call__(self, node): '''Perform split-brain test''' self.incr("calls") self.passed = 1 partitions = {} ret = self.startall(None) if not ret: return self.failure("Setup failed") while 1: # Retry until we get multiple partitions partitions = {} p_max = len(self.CM.Env["nodes"]) for node in self.CM.Env["nodes"]: p = self.CM.Env.RandomGen.randint(1, p_max) if not partitions.has_key(p): partitions[p]= [] partitions[p].append(node) p_max = len(partitions.keys()) if p_max > 1: break # else, try again self.CM.debug("Created %d partitions" % p_max) for key in partitions.keys(): self.CM.debug("Partition["+str(key)+"]:\t"+repr(partitions[key])) # Disabling STONITH to reduce test complexity for now self.CM.rsh(node, "crm_attribute -n stonith-enabled -v false") for key in partitions.keys(): self.isolate_partition(partitions[key]) count = 30 while count > 0: if len(self.CM.find_partitions()) != p_max: time.sleep(10) else: break else: self.failure("Expected partitions were not created") # Target number of partitions formed - wait for stability if not self.CM.cluster_stable(): self.failure("Partitioned cluster not stable") # Now audit the cluster state self.CM.partitions_expected = p_max if not self.audit(): self.failure("Audits failed") self.CM.partitions_expected = 1 # And heal them again for key in partitions.keys(): self.heal_partition(partitions[key]) # Wait for a single partition to form count = 30 while count > 0: if len(self.CM.find_partitions()) != 1: time.sleep(10) count -= 1 else: break else: self.failure("Cluster did not reform") # Wait for it to have the right number of members count = 30 while count > 0: members = [] partitions = self.CM.find_partitions() if len(partitions) > 0: members = partitions[0].split() if len(members) != len(self.CM.Env["nodes"]): time.sleep(10) count -= 1 else: break else: self.failure("Cluster did not completely reform") # Wait up to 20 minutes - the delay is more preferable than # trying to continue with in a messed up state if not self.CM.cluster_stable(1200): self.failure("Reformed cluster not stable") answer = raw_input('Continue? [nY]') if answer and answer == "n": raise ValueError("Reformed cluster not stable") # Turn fencing back on if self.CM.Env["DoStonith"]: self.CM.rsh(node, "crm_attribute -D -n stonith-enabled") self.CM.cluster_stable() if self.passed: return self.success() return self.failure("See previous errors") def errorstoignore(self): '''Return list of errors which are 'normal' and should be ignored''' return [ "Another DC detected:", "ERROR: attrd_cib_callback: .*Application of an update diff failed", "crmd_ha_msg_callback:.*not in our membership list", "CRIT:.*node.*returning after partition", ] def is_applicable(self): if not self.is_applicable_common(): return 0 return len(self.CM.Env["nodes"]) > 2 AllTestClasses.append(SplitBrainTest) #################################################################### class Reattach(CTSTest): #################################################################### def __init__(self, cm): CTSTest.__init__(self,cm) self.name="Reattach" self.startall = SimulStartLite(cm) self.restart1 = RestartTest(cm) self.stopall = SimulStopLite(cm) self.is_unsafe = 0 # Handled by canrunnow() def setup(self, node): return self.startall(None) def canrunnow(self, node): '''Return TRUE if we can meaningfully run right now''' if self.find_ocfs2_resources(node): self.CM.log("Detach/Reattach scenarios are not possible with OCFS2 services present") return 0 return 1 def __call__(self, node): self.incr("calls") pats = [] managed = CTS.LogWatcher(self.CM["LogFileName"], ["is-managed-default"], timeout=60) managed.setwatch() self.CM.debug("Disable resource management") self.CM.rsh(node, "crm_attribute -n is-managed-default -v false") if not managed.lookforall(): self.CM.log("Patterns not found: " + repr(managed.unmatched)) return self.failure("Resource management not disabled") pats = [] pats.append("crmd:.*Performing.*_stop_0") pats.append("crmd:.*Performing.*_start_0") pats.append("crmd:.*Performing.*_promote_0") pats.append("crmd:.*Performing.*_demote_0") pats.append("crmd:.*Performing.*_migrate_.*_0") watch = CTS.LogWatcher(self.CM["LogFileName"], pats, timeout=60) watch.setwatch() self.CM.debug("Shutting down the cluster") ret = self.stopall(None) if not ret: self.CM.debug("Re-enable resource management") self.CM.rsh(node, "crm_attribute -D -n is-managed-default") return self.failure("Couldn't shut down the cluster") self.CM.debug("Bringing the cluster back up") ret = self.startall(None) if not ret: self.CM.debug("Re-enable resource management") self.CM.rsh(node, "crm_attribute -D -n is-managed-default") return self.failure("Couldn't restart the cluster") if self.local_badnews("ResourceActivity:", watch): self.CM.debug("Re-enable resource management") self.CM.rsh(node, "crm_attribute -D -n is-managed-default") return self.failure("Resources stopped or started during cluster restart") watch = CTS.LogWatcher(self.CM["LogFileName"], pats, timeout=60) watch.setwatch() managed = CTS.LogWatcher(self.CM["LogFileName"], ["is-managed-default"], timeout=60) managed.setwatch() self.CM.debug("Re-enable resource management") self.CM.rsh(node, "crm_attribute -D -n is-managed-default") if not managed.lookforall(): self.CM.log("Patterns not found: " + repr(managed.unmatched)) return self.failure("Resource management not enabled") self.CM.cluster_stable() # Ignore actions for STONITH resources ignore = [] (rc, lines) = self.CM.rsh(node, "crm_resource -c", None) for line in lines: if re.search("^Resource", line): r = AuditResource(self.CM, line) if r.rclass == "stonith": self.CM.debug("Ignoring: crmd:.*Performing.*op=%s_.*_0" % r.id) ignore.append("crmd:.*Performing.*op=%s_.*_0" % r.id) if self.local_badnews("ResourceActivity:", watch, ignore): return self.failure("Resources stopped or started after resource management was re-enabled") return ret def errorstoignore(self): '''Return list of errors which should be ignored''' return [ "You may ignore this error if it is unmanaged.", "pingd: .*ERROR: send_ipc_message:", "pingd: .*ERROR: send_update:", "lrmd: .*ERROR: notify_client:", ] def is_applicable(self): if self.CM["Name"] == "crm-lha": return None return 1 AllTestClasses.append(Reattach) #################################################################### class SpecialTest1(CTSTest): #################################################################### '''Set up a custom test to cause quorum failure issues for Andrew''' def __init__(self, cm): CTSTest.__init__(self,cm) self.name="SpecialTest1" self.startall = SimulStartLite(cm) self.restart1 = RestartTest(cm) self.stopall = SimulStopLite(cm) def __call__(self, node): '''Perform the 'SpecialTest1' test for Andrew. ''' self.incr("calls") # Shut down all the nodes... ret = self.stopall(None) if not ret: return ret # Start the selected node ret = self.restart1(node) if not ret: return ret # Start all remaining nodes ret = self.startall(None) return ret AllTestClasses.append(SpecialTest1) #################################################################### class HAETest(CTSTest): #################################################################### '''Set up a custom test to cause quorum failure issues for Andrew''' def __init__(self, cm): CTSTest.__init__(self,cm) self.name="HAETest" self.stopall = SimulStopLite(cm) self.startall = SimulStartLite(cm) self.is_loop = 1 def setup(self, node): # Start all remaining nodes ret = self.startall(None) if not ret: return self.failure("Couldn't start all nodes") return self.success() def teardown(self, node): # Stop everything ret = self.stopall(None) if not ret: return self.failure("Couldn't stop all nodes") return self.success() def wait_on_state(self, node, resource, expected_clones, attempts=240): while attempts > 0: active=0 (rc, lines) = self.CM.rsh(node, "crm_resource -r %s -W -Q" % resource, stdout=None) # Hack until crm_resource does the right thing if rc == 0 and lines: active = len(lines) if len(lines) == expected_clones: return 1 elif rc == 1: self.CM.debug("Resource %s is still inactive" % resource) elif rc == 234: self.CM.log("Unknown resource %s" % resource) return 0 elif rc == 246: self.CM.log("Cluster is inactive") return 0 elif rc != 0: self.CM.log("Call to crm_resource failed, rc=%d" % rc) return 0 else: self.CM.debug("Resource %s is active on %d times instead of %d" % (resource, active, expected_clones)) attempts -= 1 time.sleep(1) return 0 def find_dlm(self, node): self.r_dlm = None (rc, lines) = self.CM.rsh(node, "crm_resource -c", None) for line in lines: if re.search("^Resource", line): r = AuditResource(self.CM, line) if r.rtype == "controld" and r.parent != "NA": self.CM.debug("Found dlm: %s" % self.r_dlm) self.r_dlm = r.parent return 1 return 0 def find_hae_resources(self, node): self.r_dlm = None self.r_o2cb = None self.r_ocfs2 = [] if self.find_dlm(node): self.find_ocfs2_resources(node) def is_applicable(self): if not self.is_applicable_common(): return 0 if self.CM.Env["Schema"] == "hae": return 1 return None #################################################################### class HAERoleTest(HAETest): #################################################################### def __init__(self, cm): '''Lars' mount/unmount test for the HA extension. ''' HAETest.__init__(self,cm) self.name="HAERoleTest" def change_state(self, node, resource, target): rc = self.CM.rsh(node, "crm_resource -r %s -p target-role -v %s --meta" % (resource, target)) return rc def __call__(self, node): self.incr("calls") lpc = 0 failed = 0 delay = 2 done=time.time() + self.CM.Env["loop-minutes"]*60 self.find_hae_resources(node) clone_max = len(self.CM.Env["nodes"]) while time.time() <= done and not failed: lpc = lpc + 1 self.change_state(node, self.r_dlm, "Stopped") if not self.wait_on_state(node, self.r_dlm, 0): self.failure("%s did not go down correctly" % self.r_dlm) failed = lpc self.change_state(node, self.r_dlm, "Started") if not self.wait_on_state(node, self.r_dlm, clone_max): self.failure("%s did not come up correctly" % self.r_dlm) failed = lpc if not self.wait_on_state(node, self.r_o2cb, clone_max): self.failure("%s did not come up correctly" % self.r_o2cb) failed = lpc for fs in self.r_ocfs2: if not self.wait_on_state(node, fs, clone_max): self.failure("%s did not come up correctly" % fs) failed = lpc if failed: return self.failure("iteration %d failed" % failed) return self.success() AllTestClasses.append(HAERoleTest) #################################################################### class HAEStandbyTest(HAETest): #################################################################### '''Set up a custom test to cause quorum failure issues for Andrew''' def __init__(self, cm): HAETest.__init__(self,cm) self.name="HAEStandbyTest" def change_state(self, node, resource, target): rc = self.CM.rsh(node, "crm_standby -l reboot -v %s" % (target)) return rc def __call__(self, node): self.incr("calls") lpc = 0 failed = 0 done=time.time() + self.CM.Env["loop-minutes"]*60 self.find_hae_resources(node) clone_max = len(self.CM.Env["nodes"]) while time.time() <= done and not failed: lpc = lpc + 1 self.change_state(node, self.r_dlm, "true") if not self.wait_on_state(node, self.r_dlm, clone_max-1): self.failure("%s did not go down correctly" % self.r_dlm) failed = lpc self.change_state(node, self.r_dlm, "false") if not self.wait_on_state(node, self.r_dlm, clone_max): self.failure("%s did not come up correctly" % self.r_dlm) failed = lpc if not self.wait_on_state(node, self.r_o2cb, clone_max): self.failure("%s did not come up correctly" % self.r_o2cb) failed = lpc for fs in self.r_ocfs2: if not self.wait_on_state(node, fs, clone_max): self.failure("%s did not come up correctly" % fs) failed = lpc if failed: return self.failure("iteration %d failed" % failed) return self.success() AllTestClasses.append(HAEStandbyTest) ################################################################### class NearQuorumPointTest(CTSTest): ################################################################### ''' This test brings larger clusters near the quorum point (50%). In addition, it will test doing starts and stops at the same time. Here is how I think it should work: - loop over the nodes and decide randomly which will be up and which will be down Use a 50% probability for each of up/down. - figure out what to do to get into that state from the current state - in parallel, bring up those going up and bring those going down. ''' def __init__(self, cm): CTSTest.__init__(self,cm) self.name="NearQuorumPoint" def __call__(self, dummy): '''Perform the 'NearQuorumPoint' test. ''' self.incr("calls") startset = [] stopset = [] #decide what to do with each node for node in self.CM.Env["nodes"]: action = self.CM.Env.RandomGen.choice(["start","stop"]) #action = self.CM.Env.RandomGen.choice(["start","stop","no change"]) if action == "start" : startset.append(node) elif action == "stop" : stopset.append(node) self.CM.debug("start nodes:" + repr(startset)) self.CM.debug("stop nodes:" + repr(stopset)) #add search patterns watchpats = [ ] for node in stopset: if self.CM.ShouldBeStatus[node] == "up": watchpats.append(self.CM["Pat:We_stopped"] % node) for node in startset: if self.CM.ShouldBeStatus[node] == "down": #watchpats.append(self.CM["Pat:Slave_started"] % node) watchpats.append(self.CM["Pat:Local_started"] % node) else: for stopping in stopset: if self.CM.ShouldBeStatus[stopping] == "up": watchpats.append(self.CM["Pat:They_stopped"] % (node, stopping)) if len(watchpats) == 0: return self.skipped() if len(startset) != 0: watchpats.append(self.CM["Pat:DC_IDLE"]) watch = CTS.LogWatcher(self.CM["LogFileName"], watchpats , timeout=self.CM["DeadTime"]+10) watch.setwatch() #begin actions for node in stopset: if self.CM.ShouldBeStatus[node] == "up": self.CM.StopaCMnoBlock(node) for node in startset: if self.CM.ShouldBeStatus[node] == "down": self.CM.StartaCMnoBlock(node) #get the result if watch.lookforall(): self.CM.cluster_stable() return self.success() self.CM.log("Warn: Patterns not found: " + repr(watch.unmatched)) #get the "bad" nodes upnodes = [] for node in stopset: if self.CM.StataCM(node) == 1: upnodes.append(node) downnodes = [] for node in startset: if self.CM.StataCM(node) == 0: downnodes.append(node) if upnodes == [] and downnodes == []: self.CM.cluster_stable() # Make sure they're completely down with no residule for node in stopset: self.CM.rsh(node, self.CM["StopCmd"]) return self.success() if len(upnodes) > 0: self.CM.log("Warn: Unstoppable nodes: " + repr(upnodes)) if len(downnodes) > 0: self.CM.log("Warn: Unstartable nodes: " + repr(downnodes)) return self.failure() AllTestClasses.append(NearQuorumPointTest) ################################################################### class RollingUpgradeTest(CTSTest): ################################################################### '''Perform a rolling upgrade of the cluster''' def __init__(self, cm): CTSTest.__init__(self,cm) self.name="RollingUpgrade" self.start = StartTest(cm) self.stop = StopTest(cm) self.stopall = SimulStopLite(cm) self.startall = SimulStartLite(cm) def setup(self, node): # Start all remaining nodes ret = self.stopall(None) if not ret: return self.failure("Couldn't stop all nodes") for node in self.CM.Env["nodes"]: if not self.downgrade(node, None): return self.failure("Couldn't downgrade %s" % node) ret = self.startall(None) if not ret: return self.failure("Couldn't start all nodes") return self.success() def teardown(self, node): # Stop everything ret = self.stopall(None) if not ret: return self.failure("Couldn't stop all nodes") for node in self.CM.Env["nodes"]: if not self.upgrade(node, None): return self.failure("Couldn't upgrade %s" % node) return self.success() def install(self, node, version, start=1, flags="--force"): target_dir = "/tmp/rpm-%s" % version src_dir = "%s/%s" % (self.CM.Env["rpm-dir"], version) self.CM.log("Installing %s on %s with %s" % (version, node, flags)) if not self.stop(node): return self.failure("stop failure: "+node) rc = self.CM.rsh(node, "mkdir -p %s" % target_dir) rc = self.CM.rsh(node, "rm -f %s/*.rpm" % target_dir) (rc, lines) = self.CM.rsh(node, "ls -1 %s/*.rpm" % src_dir, None) for line in lines: line = line[:-1] rc = self.CM.rsh.cp("%s" % (line), "%s:%s/" % (node, target_dir)) rc = self.CM.rsh(node, "rpm -Uvh %s %s/*.rpm" % (flags, target_dir)) if start and not self.start(node): return self.failure("start failure: "+node) return self.success() def upgrade(self, node, start=1): return self.install(node, self.CM.Env["current-version"], start) def downgrade(self, node, start=1): return self.install(node, self.CM.Env["previous-version"], start, "--force --nodeps") def __call__(self, node): '''Perform the 'Rolling Upgrade' test. ''' self.incr("calls") for node in self.CM.Env["nodes"]: if self.upgrade(node): return self.failure("Couldn't upgrade %s" % node) self.CM.cluster_stable() return self.success() def is_applicable(self): if not self.is_applicable_common(): return None if not self.CM.Env.has_key("rpm-dir"): return None if not self.CM.Env.has_key("current-version"): return None if not self.CM.Env.has_key("previous-version"): return None return 1 # Register RestartTest as a good test to run AllTestClasses.append(RollingUpgradeTest) ################################################################### class BSC_AddResource(CTSTest): ################################################################### '''Add a resource to the cluster''' def __init__(self, cm): CTSTest.__init__(self, cm) self.name="AddResource" self.resource_offset = 0 self.cib_cmd="""cibadmin -C -o %s -X '%s' """ def __call__(self, node): self.incr("calls") self.resource_offset = self.resource_offset + 1 r_id = "bsc-rsc-%s-%d" % (node, self.resource_offset) start_pat = "crmd.*%s_start_0.*confirmed.*ok" patterns = [] patterns.append(start_pat % r_id) watch = CTS.LogWatcher( self.CM["LogFileName"], patterns, self.CM["DeadTime"]) watch.setwatch() fields = string.split(self.CM.Env["IPBase"], '.') fields[3] = str(int(fields[3])+1) ip = string.join(fields, '.') self.CM.Env["IPBase"] = ip if not self.make_ip_resource(node, r_id, "ocf", "IPaddr", ip): return self.failure("Make resource %s failed" % r_id) failed = 0 watch_result = watch.lookforall() if watch.unmatched: for regex in watch.unmatched: self.CM.log ("Warn: Pattern not found: %s" % (regex)) failed = 1 if failed: return self.failure("Resource pattern(s) not found") if not self.CM.cluster_stable(self.CM["DeadTime"]): return self.failure("Unstable cluster") return self.success() def make_ip_resource(self, node, id, rclass, type, ip): self.CM.log("Creating %s::%s:%s (%s) on %s" % (rclass,type,id,ip,node)) rsc_xml=""" """ % (id, rclass, type, id, id, ip) node_constraint=""" """ % (id, id, id, id, node) rc = 0 (rc, lines) = self.CM.rsh(node, self.cib_cmd % ("constraints", node_constraint), None) if rc != 0: self.CM.log("Constraint creation failed: %d" % rc) return None (rc, lines) = self.CM.rsh(node, self.cib_cmd % ("resources", rsc_xml), None) if rc != 0: self.CM.log("Resource creation failed: %d" % rc) return None return 1 def is_applicable(self): if self.CM.Env["DoBSC"]: return 1 return None class SimulStopLite(CTSTest): ################################################################### '''Stop any active nodes ~ simultaneously''' def __init__(self, cm): CTSTest.__init__(self,cm) self.name="SimulStopLite" def __call__(self, dummy): '''Perform the 'SimulStopLite' setup work. ''' self.incr("calls") self.CM.debug("Setup: " + self.name) # We ignore the "node" parameter... watchpats = [ ] for node in self.CM.Env["nodes"]: if self.CM.ShouldBeStatus[node] == "up": self.incr("WasStarted") watchpats.append(self.CM["Pat:We_stopped"] % node) #if self.CM.Env["use_logd"]: # watchpats.append(self.CM["Pat:Logd_stopped"] % node) if len(watchpats) == 0: self.CM.clear_all_caches() return self.success() # Stop all the nodes - at about the same time... watch = CTS.LogWatcher(self.CM["LogFileName"], watchpats , timeout=self.CM["DeadTime"]+10) watch.setwatch() - self.set_starttime() + self.set_timer() for node in self.CM.Env["nodes"]: if self.CM.ShouldBeStatus[node] == "up": self.CM.StopaCMnoBlock(node) if watch.lookforall(): self.CM.clear_all_caches() # Make sure they're completely down with no residule for node in self.CM.Env["nodes"]: self.CM.rsh(node, self.CM["StopCmd"]) return self.success() did_fail=0 up_nodes = [] for node in self.CM.Env["nodes"]: if self.CM.StataCM(node) == 1: did_fail=1 up_nodes.append(node) if did_fail: return self.failure("Active nodes exist: " + repr(up_nodes)) self.CM.log("Warn: All nodes stopped but CTS didnt detect: " + repr(watch.unmatched)) self.CM.clear_all_caches() return self.failure("Missing log message: "+repr(watch.unmatched)) def is_applicable(self): '''SimulStopLite is a setup test and never applicable''' return 0 ################################################################### class SimulStartLite(CTSTest): ################################################################### '''Start any stopped nodes ~ simultaneously''' def __init__(self, cm): CTSTest.__init__(self,cm) self.name="SimulStartLite" def __call__(self, dummy): '''Perform the 'SimulStartList' setup work. ''' self.incr("calls") self.CM.debug("Setup: " + self.name) # We ignore the "node" parameter... watchpats = [ ] uppat = self.CM["Pat:Slave_started"] if self.CM.upcount() == 0: uppat = self.CM["Pat:Local_started"] for node in self.CM.Env["nodes"]: if self.CM.ShouldBeStatus[node] == "down": self.incr("WasStopped") watchpats.append(uppat % node) if len(watchpats) == 0: return self.success() watchpats.append(self.CM["Pat:DC_IDLE"]) # Start all the nodes - at about the same time... watch = CTS.LogWatcher(self.CM["LogFileName"], watchpats , timeout=self.CM["DeadTime"]+10) watch.setwatch() - self.set_starttime() + self.set_timer() for node in self.CM.Env["nodes"]: if self.CM.ShouldBeStatus[node] == "down": self.CM.StartaCMnoBlock(node) if watch.lookforall(): for attempt in (1, 2, 3, 4, 5): if self.CM.cluster_stable(): return self.success() return self.failure("Cluster did not stabilize") did_fail=0 unstable = [] for node in self.CM.Env["nodes"]: if self.CM.StataCM(node) == 0: did_fail=1 unstable.append(node) if did_fail: return self.failure("Unstarted nodes exist: " + repr(unstable)) unstable = [] for node in self.CM.Env["nodes"]: if not self.CM.node_stable(node): did_fail=1 unstable.append(node) if did_fail: return self.failure("Unstable cluster nodes exist: " + repr(unstable)) self.CM.log("ERROR: All nodes started but CTS didnt detect: " + repr(watch.unmatched)) return self.failure() def is_applicable(self): '''SimulStartLite is a setup test and never applicable''' return 0 def TestList(cm, audits): result = [] for testclass in AllTestClasses: bound_test = testclass(cm) if bound_test.is_applicable(): bound_test.Audits = audits result.append(bound_test) return result def BenchTestList(cm, audits): all = TestList(cm, audits) result = [] for test in all: if test.benchmark: result.append(test) return result # vim:ts=4:sw=4:et: diff --git a/doc/Makefile.am b/doc/Makefile.am index 283b992a96..c88229ff28 100644 --- a/doc/Makefile.am +++ b/doc/Makefile.am @@ -1,106 +1,109 @@ # # doc: Pacemaker code # # Copyright (C) 2008 Andrew Beekhof # # This program is free software; you can redistribute it and/or # modify it under the terms of the GNU General Public License # as published by the Free Software Foundation; either version 2 # of the License, or (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program; if not, write to the Free Software # Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. # MAINTAINERCLEANFILES = Makefile.in +helpdir = $(datadir)/$(PACKAGE) + ascii = crm_cli.txt crm_fencing.txt +help_DATA = crm_cli.txt docbook = Pacemaker_Explained man_MANS = cibadmin.8 crm_resource.8 doc_DATA = README.hb2openais $(ascii) $(generated_docs) publican_docs = generated_docs = XML_FILES := $(wildcard *.xml) PNG_FILES := $(wildcard images/*.png) if BUILD_ASCIIDOC generated_docs += $(ascii:%.txt=%.html) endif if BUILD_DOCBOOK publican_docs += $(docbook) endif EXTRA_DIST = $(man_MANS) $(docbook:%=%.xml) index.html: echo "Building documentation index" echo "

The following Pacemaker documentation was generated on `date` from version: $(BUILD_VERSION)

" > index.html echo "
    " >> index.html for doc in $(generated_docs); do \ echo "
  1. $$doc
  2. " >> index.html; \ done if BUILD_DOCBOOK for book in $(docbook); do \ for lang in `ls -1 $(docbook)/publish`; do \ echo "
  3. $$book ($$lang)
  4. " >> index.html; \ done; \ done endif echo "
" >> index.html echo "

You can find additional documentation and details about the Pacemaker project at http://www.clusterlabs.org

" >> index.html echo "" >> index.html %.html: %.txt $(ASCIIDOC) --unsafe --backend=xhtml11 $< %.txt: %/en-US/*.xml cd $* && $(PUBLICAN) build --publish --langs=all --formats=pdf,html,html-single,txt cp $*/publish/en-US/Pacemaker/1.0/txt/$*/$@ $@ if BUILD_DOCBOOK docbook_txt = $(docbook:%=%.txt) all-local: $(docbook_txt) #install-data-local: all-local install-data-local: all-local for book in $(docbook); do \ filelist=`find $$book/publish -print`; \ for f in $$filelist; do \ p=`echo $$f | sed s:publish/:: | sed s:Pacemaker/::`; \ if [ -d $$f ]; then \ echo $(INSTALL) -d 775 $(DESTDIR)/$(docdir)/$$p; \ else \ echo $(INSTALL) -m 644 $$f $(DESTDIR)/$(docdir)/$$p; \ fi \ done; \ done endif push: all-local index.html echo Uploading current documentation set to clusterlabs.org rsync -rtz --progress index.html root@oss.clusterlabs.org:/srv/www/extras/doc/ if BUILD_DOCBOOK for book in $(docbook); do \ echo Uploading $$book...; \ rsync -rtz --progress --delete $$book/publish/* root@oss.clusterlabs.org:/srv/www/extras/doc/; \ done endif clean-local: -rm -rf $(generated_docs) $(docbook)/tmp $(docbook)/publish diff --git a/doc/Pacemaker_Explained/en-US/Ap-FAQ.xml b/doc/Pacemaker_Explained/en-US/Ap-FAQ.xml index e7c095c75e..1f12328c18 100644 --- a/doc/Pacemaker_Explained/en-US/Ap-FAQ.xml +++ b/doc/Pacemaker_Explained/en-US/Ap-FAQ.xml @@ -1,96 +1,96 @@ FAQ History Why is the Project Called Pacemaker? First of all, the reason its not called the CRM is because of the abundance of terms that are commonly abbreviated to those three letters. The Pacemaker name came from Kham, a good friend of mine, and was originally used by a Java GUI that I was prototyping in early 2007. Alas other commitments have prevented the GUI from progressing much and, when it came time to choose a name for this project, Lars suggested it was an even better fit for an independent CRM. The idea stems from the analogy between the role of this software and that of the little device that keeps the human heart pumping. Pacemaker monitors the cluster and intervenes when necessary to ensure the smooth operation of the services it provides. There were a number of other names (and acronyms) tossed around, but suffice to say "Pacemaker" was the best Why was the Pacemaker Project Created? The decision was made to spin-off the CRM into its own project after the 2.1.3 Heartbeat release in order to support both the OpenAIS and Heartbeat cluster stacks equally decouple the release cycles of two projects at very different stages of their life-cycles foster the clearer package boundaries, thus leading to better and more stable interfaces Setup What Messaging Layers are Supported? OpenAIS () Heartbeat () Can I Choose which Messaging Layer to use at Run Time? Yes. The CRM will automatically detect who started it and behave accordingly. Can I Have a Mixed Heartbeat-OpenAIS Cluster? No. Which Messaging Layer Should I Choose? This is discussed in . Where Can I Get Pre-built Packages? - Official packages for most major .rpm and .deb based distributions are available from: - - For more information, see our installation page. + Official packages for most major .rpm and based distributions are available from: + + For Debian packages, building from source and details on using the above repositories, see our installation page. What Versions of Pacemaker Are Supported? Please refer to the Releases page for an up-to-date list of versions supported directly by the project. When seeking assistance, please try to ensure you have one of these versions. diff --git a/doc/Pacemaker_Explained/en-US/Ch-Stonith.xml b/doc/Pacemaker_Explained/en-US/Ch-Stonith.xml index c5ef7570e5..f0e511d061 100644 --- a/doc/Pacemaker_Explained/en-US/Ch-Stonith.xml +++ b/doc/Pacemaker_Explained/en-US/Ch-Stonith.xml @@ -1,84 +1,84 @@ Protecting Your Data - STONITH
Why You Need STONITH STONITH is an acronym for Shoot-The-Other-Node-In-The-Head and it protects your data from being corrupted by rouge nodes or concurrent access. Just because a node is unresponsive, this doesn't mean it isn't accessing your data. The only way to be 100% sure that your data is safe, is to use STONITH so we can be certain that the node is truly offline, before allowing the data to be accessed from another node. STONITH also has a role to play in the event that a clustered service cannot be stopped. In this case, the cluster uses STONITH to force the whole node offline, thereby making it safe to start the service elsewhere.
What STONITH Device Should You Use It is crucial that the STONITH device can allow the cluster to differentiate between a node failure and a network one. The biggest mistake people make in choosing a STONITH device is to use remote power switch (such as many on-board IMPI controllers) that shares power with the node it controls. In such cases, the cluster cannot be sure if the node is really offline, or active and suffering from a network fault. Likewise, any device that relies on the machine being active (such as SSH-based "devices" used during testing) are inappropriate.
Configuring STONITH Find the correct driver: stonith -L Since every device is different, the parameters needed to configure it will vary. To find out the parameters required by the device: stonith -t type -n Hopefully the developers chose names that make sense, if not you can query for some additional information by finding an active cluster node and running: lrmadmin -M stonith type pacemaker The output should be XML formatted text containing additional parameter descriptions Create a file called stonith.xml containing a primitive resource with a class of stonith, a type of type and a parameter for each of the values returned in step 2 Create a clone from the primitive resource if the device can shoot more than one node and supports multiple simultaneous connections. Upload it into the CIB using cibadmin: cibadmin -C -o resources --xml-file stonith.xml
Example Assuming we have an IBM BladeCenter consisting of four nodes and the management interface is active on 10.0.0.1, then we would chose the external/ibmrsa driver in step 2 and obtain the following list of parameters
Obtaining a list of STONITH Parameters stonith -t external/ibmrsa -n hostname ipaddr userid passwd type
from which we would create a STONITH resource fragment that might look like this Sample STONITH Resource - + ]]>
diff --git a/doc/publican-clusterlabs/COPYING b/doc/publican-clusterlabs/COPYING new file mode 100644 index 0000000000..44306613e2 --- /dev/null +++ b/doc/publican-clusterlabs/COPYING @@ -0,0 +1 @@ +SETUP This file should contain your COPYRIGHT License \ No newline at end of file diff --git a/doc/publican-clusterlabs/defaults.cfg b/doc/publican-clusterlabs/defaults.cfg new file mode 100644 index 0000000000..3f6cdc5c1d --- /dev/null +++ b/doc/publican-clusterlabs/defaults.cfg @@ -0,0 +1,6 @@ +# Config::Simple 4.59 +# Thu Nov 12 09:56:27 2009 + +doc_url: http://www.clusterlabs.org/wiki/Documentation +prod_url: http://www.clusterlabs.org + diff --git a/doc/publican-clusterlabs/en-US/Feedback.xml b/doc/publican-clusterlabs/en-US/Feedback.xml new file mode 100644 index 0000000000..7f0fe22ae3 --- /dev/null +++ b/doc/publican-clusterlabs/en-US/Feedback.xml @@ -0,0 +1,21 @@ + + +
+ We Need Feedback! + + feedback + contact information for this manual + + + If you find a typographical error in this manual, or if you have thought of a way to make this manual better, we would love to hear from you! + Please submit a report in Bugzilla: http://developerbugs.linux-foundation.org/ against the product &PRODUCT;. + + + When submitting a bug report, be sure to mention the manual's identifier: &BOOKID; + + + If you have a suggestion for improving the documentation, try to be as specific as possible when describing it. + If you have found an error, please include the section number and some of the surrounding text so we can find it easily. + +
diff --git a/doc/publican-clusterlabs/en-US/Legal_Notice.xml b/doc/publican-clusterlabs/en-US/Legal_Notice.xml new file mode 100644 index 0000000000..822fa40f85 --- /dev/null +++ b/doc/publican-clusterlabs/en-US/Legal_Notice.xml @@ -0,0 +1,35 @@ + + + + + Copyright &YEAR; &HOLDER;. + + + The text of and illustrations in this document are licensed under a Creative Commons Attribution–Share Alike 3.0 Unported license ("CC-BY-SA"). An explanation of CC-BY-SA is available at . + + + In accordance with CC-BY-SA, if you distribute this document or an adaptation of it, you must provide the URL for the original version. + + + In addition to the requirements of this license, the following activities are looked upon favorably: + + + + If you are distributing Open Publication works on hardcopy or CD-ROM, you provide email notification to the authors of your intent to redistribute at least thirty days before your manuscript or media freeze, to give the authors time to provide updated documents. + This notification should describe modifications, if any, made to the document. + + + + + All substantive modifications (including deletions) be either clearly marked up in the document or else described in an attachment to the document. + + + + + Finally, while it is not mandatory under this license, it is considered good form to offer a free copy of any hardcopy or CD-ROM expression of the author(s) work. + + + + + diff --git a/doc/publican-clusterlabs/en-US/css/overrides.css b/doc/publican-clusterlabs/en-US/css/overrides.css new file mode 100644 index 0000000000..7000e52428 --- /dev/null +++ b/doc/publican-clusterlabs/en-US/css/overrides.css @@ -0,0 +1,57 @@ +a:link { + color:#843A39; +} + +a:visited { + color:grey; +} + +h1 { + color:#a70000; +} + +.producttitle { + background: #800 url(../images/h1-bg.png) top left repeat; +} + +.section h1.title { + color:#843A39; +} + + +h2,h3,h4,h5,h6 { + color:#843A39; +} + +table { + border:1px solid #aaa; +} + +table th { + background-color:#900; +} + +table tr.even td { + background-color:#f5f5f5; +} + +#title a { + height:54px; +} + +.term{ + color:#a70000; +} + +.revhistory table th { + color:#a70000; +} + +.edition { + color: #a70000; +} + +span.remark{ + background-color: #ffff00; +} + diff --git a/doc/publican-clusterlabs/en-US/images/1.png b/doc/publican-clusterlabs/en-US/images/1.png new file mode 100644 index 0000000000..520ff22683 Binary files /dev/null and b/doc/publican-clusterlabs/en-US/images/1.png differ diff --git a/doc/publican-clusterlabs/en-US/images/1.svg b/doc/publican-clusterlabs/en-US/images/1.svg new file mode 100644 index 0000000000..a874e974c1 --- /dev/null +++ b/doc/publican-clusterlabs/en-US/images/1.svg @@ -0,0 +1,28 @@ + + + + + + 1 + diff --git a/doc/publican-clusterlabs/en-US/images/10.png b/doc/publican-clusterlabs/en-US/images/10.png new file mode 100644 index 0000000000..6fc0647356 Binary files /dev/null and b/doc/publican-clusterlabs/en-US/images/10.png differ diff --git a/doc/publican-clusterlabs/en-US/images/10.svg b/doc/publican-clusterlabs/en-US/images/10.svg new file mode 100644 index 0000000000..6892e0de9b --- /dev/null +++ b/doc/publican-clusterlabs/en-US/images/10.svg @@ -0,0 +1,28 @@ + + + + + + 10 + diff --git a/doc/publican-clusterlabs/en-US/images/11.png b/doc/publican-clusterlabs/en-US/images/11.png new file mode 100644 index 0000000000..2887c4c8ac Binary files /dev/null and b/doc/publican-clusterlabs/en-US/images/11.png differ diff --git a/doc/publican-clusterlabs/en-US/images/11.svg b/doc/publican-clusterlabs/en-US/images/11.svg new file mode 100644 index 0000000000..7f5c269cfc --- /dev/null +++ b/doc/publican-clusterlabs/en-US/images/11.svg @@ -0,0 +1,28 @@ + + + + + + 11 + diff --git a/doc/publican-clusterlabs/en-US/images/12.png b/doc/publican-clusterlabs/en-US/images/12.png new file mode 100644 index 0000000000..2667299e3a Binary files /dev/null and b/doc/publican-clusterlabs/en-US/images/12.png differ diff --git a/doc/publican-clusterlabs/en-US/images/12.svg b/doc/publican-clusterlabs/en-US/images/12.svg new file mode 100644 index 0000000000..9bcf3cc586 --- /dev/null +++ b/doc/publican-clusterlabs/en-US/images/12.svg @@ -0,0 +1,28 @@ + + + + + + 12 + diff --git a/doc/publican-clusterlabs/en-US/images/13.png b/doc/publican-clusterlabs/en-US/images/13.png new file mode 100644 index 0000000000..fb9f00ce66 Binary files /dev/null and b/doc/publican-clusterlabs/en-US/images/13.png differ diff --git a/doc/publican-clusterlabs/en-US/images/13.svg b/doc/publican-clusterlabs/en-US/images/13.svg new file mode 100644 index 0000000000..796664551f --- /dev/null +++ b/doc/publican-clusterlabs/en-US/images/13.svg @@ -0,0 +1,28 @@ + + + + + + 13 + diff --git a/doc/publican-clusterlabs/en-US/images/14.png b/doc/publican-clusterlabs/en-US/images/14.png new file mode 100644 index 0000000000..2f6d426846 Binary files /dev/null and b/doc/publican-clusterlabs/en-US/images/14.png differ diff --git a/doc/publican-clusterlabs/en-US/images/14.svg b/doc/publican-clusterlabs/en-US/images/14.svg new file mode 100644 index 0000000000..869be6ab2b --- /dev/null +++ b/doc/publican-clusterlabs/en-US/images/14.svg @@ -0,0 +1,28 @@ + + + + + + 14 + diff --git a/doc/publican-clusterlabs/en-US/images/15.png b/doc/publican-clusterlabs/en-US/images/15.png new file mode 100644 index 0000000000..62645715c3 Binary files /dev/null and b/doc/publican-clusterlabs/en-US/images/15.png differ diff --git a/doc/publican-clusterlabs/en-US/images/15.svg b/doc/publican-clusterlabs/en-US/images/15.svg new file mode 100644 index 0000000000..003f16c2e8 --- /dev/null +++ b/doc/publican-clusterlabs/en-US/images/15.svg @@ -0,0 +1,28 @@ + + + + + + 15 + diff --git a/doc/publican-clusterlabs/en-US/images/16.png b/doc/publican-clusterlabs/en-US/images/16.png new file mode 100644 index 0000000000..3873d725b4 Binary files /dev/null and b/doc/publican-clusterlabs/en-US/images/16.png differ diff --git a/doc/publican-clusterlabs/en-US/images/16.svg b/doc/publican-clusterlabs/en-US/images/16.svg new file mode 100644 index 0000000000..ab4bee018b --- /dev/null +++ b/doc/publican-clusterlabs/en-US/images/16.svg @@ -0,0 +1,28 @@ + + + + + + 16 + diff --git a/doc/publican-clusterlabs/en-US/images/17.png b/doc/publican-clusterlabs/en-US/images/17.png new file mode 100644 index 0000000000..66615089cb Binary files /dev/null and b/doc/publican-clusterlabs/en-US/images/17.png differ diff --git a/doc/publican-clusterlabs/en-US/images/17.svg b/doc/publican-clusterlabs/en-US/images/17.svg new file mode 100644 index 0000000000..ff29b7aa41 --- /dev/null +++ b/doc/publican-clusterlabs/en-US/images/17.svg @@ -0,0 +1,28 @@ + + + + + + 17 + diff --git a/doc/publican-clusterlabs/en-US/images/18.png b/doc/publican-clusterlabs/en-US/images/18.png new file mode 100644 index 0000000000..cf5cd4584b Binary files /dev/null and b/doc/publican-clusterlabs/en-US/images/18.png differ diff --git a/doc/publican-clusterlabs/en-US/images/18.svg b/doc/publican-clusterlabs/en-US/images/18.svg new file mode 100644 index 0000000000..6225d8a91a --- /dev/null +++ b/doc/publican-clusterlabs/en-US/images/18.svg @@ -0,0 +1,28 @@ + + + + + + 18 + diff --git a/doc/publican-clusterlabs/en-US/images/19.png b/doc/publican-clusterlabs/en-US/images/19.png new file mode 100644 index 0000000000..0e481be1fe Binary files /dev/null and b/doc/publican-clusterlabs/en-US/images/19.png differ diff --git a/doc/publican-clusterlabs/en-US/images/19.svg b/doc/publican-clusterlabs/en-US/images/19.svg new file mode 100644 index 0000000000..efd3c0eeb9 --- /dev/null +++ b/doc/publican-clusterlabs/en-US/images/19.svg @@ -0,0 +1,28 @@ + + + + + + 19 + diff --git a/doc/publican-clusterlabs/en-US/images/2.png b/doc/publican-clusterlabs/en-US/images/2.png new file mode 100644 index 0000000000..ccaa4240d6 Binary files /dev/null and b/doc/publican-clusterlabs/en-US/images/2.png differ diff --git a/doc/publican-clusterlabs/en-US/images/2.svg b/doc/publican-clusterlabs/en-US/images/2.svg new file mode 100644 index 0000000000..27100aca9f --- /dev/null +++ b/doc/publican-clusterlabs/en-US/images/2.svg @@ -0,0 +1,28 @@ + + + + + + 2 + diff --git a/doc/publican-clusterlabs/en-US/images/20.png b/doc/publican-clusterlabs/en-US/images/20.png new file mode 100644 index 0000000000..a3852a14e2 Binary files /dev/null and b/doc/publican-clusterlabs/en-US/images/20.png differ diff --git a/doc/publican-clusterlabs/en-US/images/20.svg b/doc/publican-clusterlabs/en-US/images/20.svg new file mode 100644 index 0000000000..7d727359a3 --- /dev/null +++ b/doc/publican-clusterlabs/en-US/images/20.svg @@ -0,0 +1,28 @@ + + + + + + 20 + diff --git a/doc/publican-clusterlabs/en-US/images/21.png b/doc/publican-clusterlabs/en-US/images/21.png new file mode 100644 index 0000000000..b958a30b0b Binary files /dev/null and b/doc/publican-clusterlabs/en-US/images/21.png differ diff --git a/doc/publican-clusterlabs/en-US/images/21.svg b/doc/publican-clusterlabs/en-US/images/21.svg new file mode 100644 index 0000000000..babe3ad790 --- /dev/null +++ b/doc/publican-clusterlabs/en-US/images/21.svg @@ -0,0 +1,28 @@ + + + + + + 21 + diff --git a/doc/publican-clusterlabs/en-US/images/22.png b/doc/publican-clusterlabs/en-US/images/22.png new file mode 100644 index 0000000000..e4c68b1407 Binary files /dev/null and b/doc/publican-clusterlabs/en-US/images/22.png differ diff --git a/doc/publican-clusterlabs/en-US/images/22.svg b/doc/publican-clusterlabs/en-US/images/22.svg new file mode 100644 index 0000000000..d7c7af500d --- /dev/null +++ b/doc/publican-clusterlabs/en-US/images/22.svg @@ -0,0 +1,28 @@ + + + + + + 22 + diff --git a/doc/publican-clusterlabs/en-US/images/23.png b/doc/publican-clusterlabs/en-US/images/23.png new file mode 100644 index 0000000000..a627327317 Binary files /dev/null and b/doc/publican-clusterlabs/en-US/images/23.png differ diff --git a/doc/publican-clusterlabs/en-US/images/23.svg b/doc/publican-clusterlabs/en-US/images/23.svg new file mode 100644 index 0000000000..399deffb41 --- /dev/null +++ b/doc/publican-clusterlabs/en-US/images/23.svg @@ -0,0 +1,28 @@ + + + + + + 23 + diff --git a/doc/publican-clusterlabs/en-US/images/24.png b/doc/publican-clusterlabs/en-US/images/24.png new file mode 100644 index 0000000000..bdcea873a0 Binary files /dev/null and b/doc/publican-clusterlabs/en-US/images/24.png differ diff --git a/doc/publican-clusterlabs/en-US/images/24.svg b/doc/publican-clusterlabs/en-US/images/24.svg new file mode 100644 index 0000000000..25a37e8dc8 --- /dev/null +++ b/doc/publican-clusterlabs/en-US/images/24.svg @@ -0,0 +1,28 @@ + + + + + + 24 + diff --git a/doc/publican-clusterlabs/en-US/images/25.png b/doc/publican-clusterlabs/en-US/images/25.png new file mode 100644 index 0000000000..db5a9eeedb Binary files /dev/null and b/doc/publican-clusterlabs/en-US/images/25.png differ diff --git a/doc/publican-clusterlabs/en-US/images/25.svg b/doc/publican-clusterlabs/en-US/images/25.svg new file mode 100644 index 0000000000..adfb67af3e --- /dev/null +++ b/doc/publican-clusterlabs/en-US/images/25.svg @@ -0,0 +1,28 @@ + + + + + + 25 + diff --git a/doc/publican-clusterlabs/en-US/images/26.png b/doc/publican-clusterlabs/en-US/images/26.png new file mode 100644 index 0000000000..4bf703699f Binary files /dev/null and b/doc/publican-clusterlabs/en-US/images/26.png differ diff --git a/doc/publican-clusterlabs/en-US/images/26.svg b/doc/publican-clusterlabs/en-US/images/26.svg new file mode 100644 index 0000000000..6e8e5d62b8 --- /dev/null +++ b/doc/publican-clusterlabs/en-US/images/26.svg @@ -0,0 +1,28 @@ + + + + + + 26 + diff --git a/doc/publican-clusterlabs/en-US/images/27.png b/doc/publican-clusterlabs/en-US/images/27.png new file mode 100644 index 0000000000..d0105b0a43 Binary files /dev/null and b/doc/publican-clusterlabs/en-US/images/27.png differ diff --git a/doc/publican-clusterlabs/en-US/images/27.svg b/doc/publican-clusterlabs/en-US/images/27.svg new file mode 100644 index 0000000000..299194e448 --- /dev/null +++ b/doc/publican-clusterlabs/en-US/images/27.svg @@ -0,0 +1,28 @@ + + + + + + 27 + diff --git a/doc/publican-clusterlabs/en-US/images/28.png b/doc/publican-clusterlabs/en-US/images/28.png new file mode 100644 index 0000000000..19eac5c489 Binary files /dev/null and b/doc/publican-clusterlabs/en-US/images/28.png differ diff --git a/doc/publican-clusterlabs/en-US/images/28.svg b/doc/publican-clusterlabs/en-US/images/28.svg new file mode 100644 index 0000000000..5df71b8555 --- /dev/null +++ b/doc/publican-clusterlabs/en-US/images/28.svg @@ -0,0 +1,28 @@ + + + + + + 28 + diff --git a/doc/publican-clusterlabs/en-US/images/29.png b/doc/publican-clusterlabs/en-US/images/29.png new file mode 100644 index 0000000000..e64d4e6e32 Binary files /dev/null and b/doc/publican-clusterlabs/en-US/images/29.png differ diff --git a/doc/publican-clusterlabs/en-US/images/29.svg b/doc/publican-clusterlabs/en-US/images/29.svg new file mode 100644 index 0000000000..88aa692be4 --- /dev/null +++ b/doc/publican-clusterlabs/en-US/images/29.svg @@ -0,0 +1,28 @@ + + + + + + 29 + diff --git a/doc/publican-clusterlabs/en-US/images/3.png b/doc/publican-clusterlabs/en-US/images/3.png new file mode 100644 index 0000000000..73478793d5 Binary files /dev/null and b/doc/publican-clusterlabs/en-US/images/3.png differ diff --git a/doc/publican-clusterlabs/en-US/images/3.svg b/doc/publican-clusterlabs/en-US/images/3.svg new file mode 100644 index 0000000000..7954fa5a0d --- /dev/null +++ b/doc/publican-clusterlabs/en-US/images/3.svg @@ -0,0 +1,28 @@ + + + + + + 3 + diff --git a/doc/publican-clusterlabs/en-US/images/4.png b/doc/publican-clusterlabs/en-US/images/4.png new file mode 100644 index 0000000000..9ae22affd1 Binary files /dev/null and b/doc/publican-clusterlabs/en-US/images/4.png differ diff --git a/doc/publican-clusterlabs/en-US/images/4.svg b/doc/publican-clusterlabs/en-US/images/4.svg new file mode 100644 index 0000000000..c97f7658a5 --- /dev/null +++ b/doc/publican-clusterlabs/en-US/images/4.svg @@ -0,0 +1,28 @@ + + + + + + 4 + diff --git a/doc/publican-clusterlabs/en-US/images/5.png b/doc/publican-clusterlabs/en-US/images/5.png new file mode 100644 index 0000000000..bba793a77a Binary files /dev/null and b/doc/publican-clusterlabs/en-US/images/5.png differ diff --git a/doc/publican-clusterlabs/en-US/images/5.svg b/doc/publican-clusterlabs/en-US/images/5.svg new file mode 100644 index 0000000000..6450446938 --- /dev/null +++ b/doc/publican-clusterlabs/en-US/images/5.svg @@ -0,0 +1,28 @@ + + + + + + 5 + diff --git a/doc/publican-clusterlabs/en-US/images/6.png b/doc/publican-clusterlabs/en-US/images/6.png new file mode 100644 index 0000000000..b5483fbb58 Binary files /dev/null and b/doc/publican-clusterlabs/en-US/images/6.png differ diff --git a/doc/publican-clusterlabs/en-US/images/6.svg b/doc/publican-clusterlabs/en-US/images/6.svg new file mode 100644 index 0000000000..45af47a1cd --- /dev/null +++ b/doc/publican-clusterlabs/en-US/images/6.svg @@ -0,0 +1,28 @@ + + + + + + 6 + diff --git a/doc/publican-clusterlabs/en-US/images/7.png b/doc/publican-clusterlabs/en-US/images/7.png new file mode 100644 index 0000000000..d085f2d805 Binary files /dev/null and b/doc/publican-clusterlabs/en-US/images/7.png differ diff --git a/doc/publican-clusterlabs/en-US/images/7.svg b/doc/publican-clusterlabs/en-US/images/7.svg new file mode 100644 index 0000000000..2e9ffec986 --- /dev/null +++ b/doc/publican-clusterlabs/en-US/images/7.svg @@ -0,0 +1,28 @@ + + + + + + 7 + diff --git a/doc/publican-clusterlabs/en-US/images/8.png b/doc/publican-clusterlabs/en-US/images/8.png new file mode 100644 index 0000000000..f37327163d Binary files /dev/null and b/doc/publican-clusterlabs/en-US/images/8.png differ diff --git a/doc/publican-clusterlabs/en-US/images/8.svg b/doc/publican-clusterlabs/en-US/images/8.svg new file mode 100644 index 0000000000..340dbce58e --- /dev/null +++ b/doc/publican-clusterlabs/en-US/images/8.svg @@ -0,0 +1,28 @@ + + + + + + 8 + diff --git a/doc/publican-clusterlabs/en-US/images/9.png b/doc/publican-clusterlabs/en-US/images/9.png new file mode 100644 index 0000000000..e8709d448b Binary files /dev/null and b/doc/publican-clusterlabs/en-US/images/9.png differ diff --git a/doc/publican-clusterlabs/en-US/images/9.svg b/doc/publican-clusterlabs/en-US/images/9.svg new file mode 100644 index 0000000000..3838627082 --- /dev/null +++ b/doc/publican-clusterlabs/en-US/images/9.svg @@ -0,0 +1,28 @@ + + + + + + 9 + diff --git a/doc/publican-clusterlabs/en-US/images/Pacemaker-stack.svg b/doc/publican-clusterlabs/en-US/images/Pacemaker-stack.svg new file mode 100644 index 0000000000..54da570000 --- /dev/null +++ b/doc/publican-clusterlabs/en-US/images/Pacemaker-stack.svg @@ -0,0 +1,1083 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + image/svg+xml + + + + + + + + + + + + + + + + + OpenAIS + + LRM + + SBD + + dlm_controld + + ocfs2_controld + + clvmd + + Pacemaker + + CIB + + PolicyEngine + + + ext3, XFS + OCFS2 + cLVM2 + DRBD + Multipath IO + Local disks + + SANFC(oE), iSCSI + + + DLM + SCTP + TCP + Ethernet + Infiniband + Bonding + UDPmulticast + + + Fat GUI + + CRM Shell + + Web GUI + + + Filesystems + + IP address + + DRBD + + iSCSI + + Apache + + SAP + + OCF agents + + Xen + + libvirt + + MySQL + + LSB + + + STONITH + + + iLO + + DRAC + + ... + + + + Fencing + + + Linux kernel + + + + + + + + + + + + + + diff --git a/doc/publican-clusterlabs/en-US/images/dot.png b/doc/publican-clusterlabs/en-US/images/dot.png new file mode 100644 index 0000000000..079add95de Binary files /dev/null and b/doc/publican-clusterlabs/en-US/images/dot.png differ diff --git a/doc/publican-clusterlabs/en-US/images/dot.svg b/doc/publican-clusterlabs/en-US/images/dot.svg new file mode 100644 index 0000000000..eaeff2ea78 --- /dev/null +++ b/doc/publican-clusterlabs/en-US/images/dot.svg @@ -0,0 +1,21 @@ + + + + dot + diff --git a/doc/publican-clusterlabs/en-US/images/dot2.png b/doc/publican-clusterlabs/en-US/images/dot2.png new file mode 100644 index 0000000000..8348fcd054 Binary files /dev/null and b/doc/publican-clusterlabs/en-US/images/dot2.png differ diff --git a/doc/publican-clusterlabs/en-US/images/dot2.svg b/doc/publican-clusterlabs/en-US/images/dot2.svg new file mode 100644 index 0000000000..893f689356 --- /dev/null +++ b/doc/publican-clusterlabs/en-US/images/dot2.svg @@ -0,0 +1,21 @@ + + + + dot2 + diff --git a/doc/publican-clusterlabs/en-US/images/h1-bg.png b/doc/publican-clusterlabs/en-US/images/h1-bg.png new file mode 100644 index 0000000000..ce080e772e Binary files /dev/null and b/doc/publican-clusterlabs/en-US/images/h1-bg.png differ diff --git a/doc/publican-clusterlabs/en-US/images/h1-bg.svg b/doc/publican-clusterlabs/en-US/images/h1-bg.svg new file mode 100644 index 0000000000..7dcf47b645 --- /dev/null +++ b/doc/publican-clusterlabs/en-US/images/h1-bg.svg @@ -0,0 +1,95 @@ + + + + + + image/svg+xml + + + + + + + + + + + + + + h1-bg + + diff --git a/doc/publican-clusterlabs/en-US/images/image_left.png b/doc/publican-clusterlabs/en-US/images/image_left.png new file mode 100644 index 0000000000..f781295359 Binary files /dev/null and b/doc/publican-clusterlabs/en-US/images/image_left.png differ diff --git a/doc/publican-clusterlabs/en-US/images/image_left.svg b/doc/publican-clusterlabs/en-US/images/image_left.svg new file mode 100644 index 0000000000..4ce5460a8c --- /dev/null +++ b/doc/publican-clusterlabs/en-US/images/image_left.svg @@ -0,0 +1,237 @@ + + + + + + + + image/svg+xml + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Pacemaker + + + Pacemaker + + diff --git a/doc/publican-clusterlabs/en-US/images/image_right.png b/doc/publican-clusterlabs/en-US/images/image_right.png new file mode 100644 index 0000000000..9ec1ac5491 Binary files /dev/null and b/doc/publican-clusterlabs/en-US/images/image_right.png differ diff --git a/doc/publican-clusterlabs/en-US/images/image_right.svg b/doc/publican-clusterlabs/en-US/images/image_right.svg new file mode 100644 index 0000000000..205f021f5a --- /dev/null +++ b/doc/publican-clusterlabs/en-US/images/image_right.svg @@ -0,0 +1,99 @@ + + + + + + + + image/svg+xml + + + + + + + + + + clusterlabs + + + documentation + diff --git a/doc/publican-clusterlabs/en-US/images/important.png b/doc/publican-clusterlabs/en-US/images/important.png new file mode 100644 index 0000000000..969562b7bc Binary files /dev/null and b/doc/publican-clusterlabs/en-US/images/important.png differ diff --git a/doc/publican-clusterlabs/en-US/images/important.svg b/doc/publican-clusterlabs/en-US/images/important.svg new file mode 100644 index 0000000000..064c783b53 --- /dev/null +++ b/doc/publican-clusterlabs/en-US/images/important.svg @@ -0,0 +1,30 @@ + + + + + + + + + diff --git a/doc/publican-clusterlabs/en-US/images/note.png b/doc/publican-clusterlabs/en-US/images/note.png new file mode 100644 index 0000000000..d04775d990 Binary files /dev/null and b/doc/publican-clusterlabs/en-US/images/note.png differ diff --git a/doc/publican-clusterlabs/en-US/images/note.svg b/doc/publican-clusterlabs/en-US/images/note.svg new file mode 100644 index 0000000000..abe5a60246 --- /dev/null +++ b/doc/publican-clusterlabs/en-US/images/note.svg @@ -0,0 +1,28 @@ + + + + + + + + + diff --git a/doc/publican-clusterlabs/en-US/images/pacemaker-logo.png b/doc/publican-clusterlabs/en-US/images/pacemaker-logo.png new file mode 100644 index 0000000000..f5ea2c68a3 Binary files /dev/null and b/doc/publican-clusterlabs/en-US/images/pacemaker-logo.png differ diff --git a/doc/publican-clusterlabs/en-US/images/pacemaker_logo.svg b/doc/publican-clusterlabs/en-US/images/pacemaker_logo.svg new file mode 100644 index 0000000000..a86bea1b06 --- /dev/null +++ b/doc/publican-clusterlabs/en-US/images/pacemaker_logo.svg @@ -0,0 +1,145 @@ + + + + + + + + image/svg+xml + + + + + + + + + + + + + + + + + + + + + + + + + + + Pacemaker + + diff --git a/doc/publican-clusterlabs/en-US/images/shine.png b/doc/publican-clusterlabs/en-US/images/shine.png new file mode 100644 index 0000000000..a18f7c4612 Binary files /dev/null and b/doc/publican-clusterlabs/en-US/images/shine.png differ diff --git a/doc/publican-clusterlabs/en-US/images/stock-go-back.png b/doc/publican-clusterlabs/en-US/images/stock-go-back.png new file mode 100644 index 0000000000..00850b21b2 Binary files /dev/null and b/doc/publican-clusterlabs/en-US/images/stock-go-back.png differ diff --git a/doc/publican-clusterlabs/en-US/images/stock-go-back.svg b/doc/publican-clusterlabs/en-US/images/stock-go-back.svg new file mode 100644 index 0000000000..b3b908143f --- /dev/null +++ b/doc/publican-clusterlabs/en-US/images/stock-go-back.svg @@ -0,0 +1,21 @@ + + + + stock-go-back + diff --git a/doc/publican-clusterlabs/en-US/images/stock-go-forward.png b/doc/publican-clusterlabs/en-US/images/stock-go-forward.png new file mode 100644 index 0000000000..cc2797a468 Binary files /dev/null and b/doc/publican-clusterlabs/en-US/images/stock-go-forward.png differ diff --git a/doc/publican-clusterlabs/en-US/images/stock-go-forward.svg b/doc/publican-clusterlabs/en-US/images/stock-go-forward.svg new file mode 100644 index 0000000000..7ee607b48f --- /dev/null +++ b/doc/publican-clusterlabs/en-US/images/stock-go-forward.svg @@ -0,0 +1,21 @@ + + + + stock-go-forward + diff --git a/doc/publican-clusterlabs/en-US/images/stock-go-up.png b/doc/publican-clusterlabs/en-US/images/stock-go-up.png new file mode 100644 index 0000000000..1ebf2799c3 Binary files /dev/null and b/doc/publican-clusterlabs/en-US/images/stock-go-up.png differ diff --git a/doc/publican-clusterlabs/en-US/images/stock-go-up.svg b/doc/publican-clusterlabs/en-US/images/stock-go-up.svg new file mode 100644 index 0000000000..a7c2af2f15 --- /dev/null +++ b/doc/publican-clusterlabs/en-US/images/stock-go-up.svg @@ -0,0 +1,21 @@ + + + + stock-go-up + diff --git a/doc/publican-clusterlabs/en-US/images/stock-home.png b/doc/publican-clusterlabs/en-US/images/stock-home.png new file mode 100644 index 0000000000..3f0c190634 Binary files /dev/null and b/doc/publican-clusterlabs/en-US/images/stock-home.png differ diff --git a/doc/publican-clusterlabs/en-US/images/stock-home.svg b/doc/publican-clusterlabs/en-US/images/stock-home.svg new file mode 100644 index 0000000000..d06a54480e --- /dev/null +++ b/doc/publican-clusterlabs/en-US/images/stock-home.svg @@ -0,0 +1,21 @@ + + + + stock-home + diff --git a/doc/publican-clusterlabs/en-US/images/title_logo.png b/doc/publican-clusterlabs/en-US/images/title_logo.png new file mode 100644 index 0000000000..aa7915a690 Binary files /dev/null and b/doc/publican-clusterlabs/en-US/images/title_logo.png differ diff --git a/doc/publican-clusterlabs/en-US/images/title_logo.svg b/doc/publican-clusterlabs/en-US/images/title_logo.svg new file mode 100644 index 0000000000..a86bea1b06 --- /dev/null +++ b/doc/publican-clusterlabs/en-US/images/title_logo.svg @@ -0,0 +1,145 @@ + + + + + + + + image/svg+xml + + + + + + + + + + + + + + + + + + + + + + + + + + + Pacemaker + + diff --git a/doc/publican-clusterlabs/en-US/images/warning.png b/doc/publican-clusterlabs/en-US/images/warning.png new file mode 100644 index 0000000000..94b69d1ff1 Binary files /dev/null and b/doc/publican-clusterlabs/en-US/images/warning.png differ diff --git a/doc/publican-clusterlabs/en-US/images/warning.svg b/doc/publican-clusterlabs/en-US/images/warning.svg new file mode 100644 index 0000000000..4231e5ac04 --- /dev/null +++ b/doc/publican-clusterlabs/en-US/images/warning.svg @@ -0,0 +1,130 @@ + + + + + + + image/svg+xml + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/doc/publican-clusterlabs/en-US/images/watermark-draft.png b/doc/publican-clusterlabs/en-US/images/watermark-draft.png new file mode 100644 index 0000000000..0ead5af8bb Binary files /dev/null and b/doc/publican-clusterlabs/en-US/images/watermark-draft.png differ diff --git a/doc/publican-clusterlabs/en-US/images/watermark-draft.svg b/doc/publican-clusterlabs/en-US/images/watermark-draft.svg new file mode 100644 index 0000000000..4ecbf37fec --- /dev/null +++ b/doc/publican-clusterlabs/en-US/images/watermark-draft.svg @@ -0,0 +1,21 @@ + + + + watermark-draft + diff --git a/doc/publican-clusterlabs/overrides.cfg b/doc/publican-clusterlabs/overrides.cfg new file mode 100644 index 0000000000..4505371868 --- /dev/null +++ b/doc/publican-clusterlabs/overrides.cfg @@ -0,0 +1,5 @@ +# Config::Simple 4.59 +# Thu Nov 12 09:56:27 2009 + +strict: 0 + diff --git a/doc/publican-clusterlabs/publican-clusterlabs.spec b/doc/publican-clusterlabs/publican-clusterlabs.spec new file mode 100644 index 0000000000..9d0cbe73a4 --- /dev/null +++ b/doc/publican-clusterlabs/publican-clusterlabs.spec @@ -0,0 +1,43 @@ +%define brand clusterlabs + +Name: publican-clusterlabs +Summary: Common documentation files for %{brand} +Version: 0.1 +Release: 0%{?dist} +License: SETUP: Set This +Group: Applications/Text +Buildroot: %{_tmppath}/%{name}-%{version}-%{release}-root-%(%{__id_u} -n) +Buildarch: noarch +Source: https://www.SETUP.set.me.example.com/source/%{name}-%{version}.tgz +Requires: publican >= 1.0 +BuildRequires: publican >= 1.0 +URL: https://www.SETUP.set.me.example.com + +%description +This package provides common files and templates needed to build documentation +for %{brand} with publican. + +%prep +%setup -q + +%build +publican build --formats=xml --langs=all --publish + +%install +rm -rf $RPM_BUILD_ROOT +mkdir -p -m755 $RPM_BUILD_ROOT%{_datadir}/publican/Common_Content +publican installbrand --path=$RPM_BUILD_ROOT%{_datadir}/publican/Common_Content + +%clean +rm -rf $RPM_BUILD_ROOT + +%files +%defattr(-,root,root,-) +%doc README +%doc COPYING +%{_datadir}/publican/Common_Content/%{brand} + +%changelog +* Thu Nov 12 2009 SETUP:YourName 0.1 +- Created Brand + diff --git a/doc/publican-clusterlabs/publican.cfg b/doc/publican-clusterlabs/publican.cfg new file mode 100644 index 0000000000..f48c15064a --- /dev/null +++ b/doc/publican-clusterlabs/publican.cfg @@ -0,0 +1,9 @@ +# Config::Simple 4.59 +# Thu Nov 12 09:56:27 2009 + +version: 0.1 +xml_lang: en-US +release: 0 +type: brand +brand: clusterlabs + diff --git a/doc/publican-clusterlabs/xsl/common.xsl b/doc/publican-clusterlabs/xsl/common.xsl new file mode 100644 index 0000000000..7e4daca81f --- /dev/null +++ b/doc/publican-clusterlabs/xsl/common.xsl @@ -0,0 +1,57 @@ + + + + + + + ]> + + + +#843A39 + + +appendix toc,title +article/appendix nop +article toc,title +book toc,title,figure,table,example,equation +chapter toc,title +part toc,title +preface toc,title +qandadiv nop +qandaset nop +reference toc,title +sect1 nop +sect2 nop +sect3 nop +sect4 nop +sect5 nop +section nop +set toc,title + + + + diff --git a/doc/publican-clusterlabs/xsl/html-single.xsl b/doc/publican-clusterlabs/xsl/html-single.xsl new file mode 100644 index 0000000000..c55bf35db5 --- /dev/null +++ b/doc/publican-clusterlabs/xsl/html-single.xsl @@ -0,0 +1,24 @@ + + + + + + + ]> + + + + + + + + diff --git a/doc/publican-clusterlabs/xsl/html.xsl b/doc/publican-clusterlabs/xsl/html.xsl new file mode 100644 index 0000000000..847a595da3 --- /dev/null +++ b/doc/publican-clusterlabs/xsl/html.xsl @@ -0,0 +1,30 @@ + + + + + + + ]> + + + + + + + + + + + + + + diff --git a/doc/publican-clusterlabs/xsl/pdf.xsl b/doc/publican-clusterlabs/xsl/pdf.xsl new file mode 100644 index 0000000000..5d2f25c339 --- /dev/null +++ b/doc/publican-clusterlabs/xsl/pdf.xsl @@ -0,0 +1,26 @@ + + + + + + + ]> + + + + + + + + + + diff --git a/extra/resources/HealthSMART b/extra/resources/HealthSMART index 6a0801fc42..2c78a87b30 100644 --- a/extra/resources/HealthSMART +++ b/extra/resources/HealthSMART @@ -1,278 +1,287 @@ #!/bin/sh # # # HealthSMART OCF RA. Checks the S.M.A.R.T. status of all given # drives and writes the #health-smart status into the CIB # # Copyright (c) 2009 Michael Schwartzkopff # # All Rights Reserved. # # This program is free software; you can redistribute it and/or modify # it under the terms of version 2 of the GNU General Public License as # published by the Free Software Foundation. # # This program is distributed in the hope that it would be useful, but # WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. # # Further, this software is distributed without any warranty that it is # free of the rightful claim of any third person regarding infringement # or the like. Any license provided herein, whether implied or # otherwise, applies only to this software file. Patent licenses, if # any, provided herein do not apply to combinations of this program with # other software, or any other product whatsoever. # # You should have received a copy of the GNU General Public License # along with this program; if not, write the Free Software Foundation, # Inc., 59 Temple Place - Suite 330, Boston MA 02111-1307, USA. # ################################ # # TODO: # - All # - Enable drive parameter with a loop. # - Error handling if smart does not give temeprature. # ################################## ####################################################################### # Initialization: . ${OCF_ROOT}/resource.d/heartbeat/.ocf-shellfuncs # SMARTCTL=/usr/sbin/smartctl ####################################################################### meta_data() { cat < 0.1 Systhem health agent that checks the S.M.A.R.T. status of the given drives and updates the #health-smart attribute. SMART health status Location to store the resource state in. State file The drives to check as a SPACE separated list. Enter only the part after the "/dev/" i.e. "sda". At the moment /dev/sda is hard coded. Sorry. Drives to check Lower limit of the temperature in deg C of the drive(s). Below this limit there status will be red. The yellow limit is 5 deg C more than this value. Lower limit for the temperature of the drive(s) Upper limit of the temperature if deg C of the drives(s). If the drive reports a temperature higher than this value the status of #health-smart will be red. The yellow limit is 5 deg C below this value. Upper limit for red smart attribute END } ####################################################################### +init_smart() { + + if [ "x${OCF_RESKEY_temp_lower_limit}" = "x" ] ; then + lower_red_limit=0 + lower_yellow_limit=5 + else + lower_red_limit=${OCF_RESKEY_temp_lower_limit} + let lower_yellow_limit=${OCF_RESKEY_temp_lower_limit}+5 + fi + + if [ "x${OCF_RESKEY_temp_upper_limit}" = "x" ] ; then + upper_red_limit=60 + upper_yellow_limit=55 + else + upper_red_limit=${OCF_RESKEY_temp_upper_limit} + let upper_yellow_limit=${OCF_RESKEY_temp_upper_limit}-5 + fi + + if [ "x${OCF_RESKEY_drives}" = "x" ] ; then + DRIVES="sda" + else + DRIVES=${OCF_RESKEY_drives} + fi + + # echo "Drives: "$DRIVES, "Lower limits: "$lower_red_limit, $lower_yellow_limit, "Upper limits: "$upper_red_limit, $upper_yellow_limit + + if [ ! -x $SMARTCTL ] ; then + ocf_log err $SMARTCTL" not installed." + exit $OCF_ERR_INSTALLED + fi + + $SMARTCTL -i $DRIVE | grep -q "SMART support is: Enabled" + ret=$? + if [ $ret -ne "0" ] ; then + ocf_log err "S.M.A.R.T. not enabled for drive /dev/"${DRIVE} + exit $OCF_ERR_INSTALLED + fi + +} + # don't exit on TERM, to test that lrmd makes sure that we do exit trap sigterm_handler TERM sigterm_handler() { ocf_log info "They use TERM to bring us down. No such luck." return } dummy_usage() { cat < 1.0 Every time the monitor action is run, this resource agent records (in the CIB) the current number of ping nodes the host can connect to. It is essentially the same as pingd except that it uses the system ping tool to obtain the results. node connectivity PID file PID file The time to wait (dampening) further changes occur Dampening interval The name of the attributes to set. This is the name to be used in the constraints. Attribute name The number by which to multiply the number of connected ping nodes by Value multiplier The list of ping nodes to count. Defaults to all configured ping nodes. Rarely needs to be specified. Host list Number of ping attempts, per host, before declaring it dead no. of ping attempts How long, in seconds, to wait before declaring a ping lost ping timeout in seconds A catch all for any other options that need to be passed to ping. Extra Options Enables to use default attrd_updater verbose logging on every call. Verbose logging - - + + - + END } ####################################################################### # don't exit on TERM, to test that lrmd makes sure that we do exit trap sigterm_handler TERM sigterm_handler() { ocf_log info "They use TERM to bring us down. No such luck." return } ping_usage() { cat <&1`; rc=$? case $rc in 0) active=`expr $active + 1`;; 1) ocf_log debug "$host is inactive: $p_out";; *) ocf_log err "Unexpected result for '$p_exe $p_args $OCF_RESKEY_options $host' $rc: $p_out";; esac done score=`expr $active \* $OCF_RESKEY_multiplier` attrd_updater -n $OCF_RESKEY_name -v $score -d $OCF_RESKEY_dampen $attrd_options } : ${OCF_RESKEY_name:="pingd"} : ${OCF_RESKEY_dampen:="5s"} : ${OCF_RESKEY_attempts:="5"} : ${OCF_RESKEY_multiplier:="1"} : ${OCF_RESKEY_debug:="false"} -: ${OCF_RESKEY_CRM_meta_timeout=20} -: ${OCF_RESKEY_CRM_meta_interval=10} +: ${OCF_RESKEY_CRM_meta_timeout:="60"} +: ${OCF_RESKEY_CRM_meta_interval="10"} : ${OCF_RESKEY_CRM_meta_globally_unique:="true"} if [ -z ${OCF_RESKEY_timeout} ]; then OCF_RESKEY_timeout=`expr $OCF_RESKEY_CRM_meta_timeout / $OCF_RESKEY_attempts` OCF_RESKEY_timeout=`expr $OCF_RESKEY_timeout / 1100` # Convert to seconds and finish 10% early fi if [ ${OCF_RESKEY_timeout} -lt 1 ]; then OCF_RESKEY_timeout=5 elif [ ${OCF_RESKEY_timeout} -gt 1000 ]; then # ping actually complains if this value is too high, 5 minutes is plenty OCF_RESKEY_timeout=300 fi if [ ${OCF_RESKEY_CRM_meta_globally_unique} = "false" ]; then : ${OCF_RESKEY_pidfile:="$HA_VARRUN/ping-${OCF_RESKEY_name}"} else : ${OCF_RESKEY_pidfile:="$HA_VARRUN/ping-${OCF_RESOURCE_INSTANCE}"} fi attrd_options='-q' if ocf_is_true ${OCF_RESKEY_debug} ; then attrd_options='' fi case $__OCF_ACTION in meta-data) meta_data exit $OCF_SUCCESS ;; start) ping_start;; stop) ping_stop;; monitor) ping_monitor;; reload) ping_start;; validate-all) ping_validate;; usage|help) ping_usage exit $OCF_SUCCESS ;; *) ping_usage exit $OCF_ERR_UNIMPLEMENTED ;; esac exit $? diff --git a/pacemaker.spec b/pacemaker.spec index 1b38ba3284..0f0e8ef3aa 100644 --- a/pacemaker.spec +++ b/pacemaker.spec @@ -1,1263 +1,1282 @@ %global gname haclient %global uname hacluster -%global with_ais_support 1 -%global with_heartbeat_support 1 %global pcmk_docdir %{_docdir}/%{name} %global specversion 2 #global upstream_version ee19d8e83c2a %global upstream_prefix pacemaker # Keep around for when/if required #global alphatag %{upstream_version}.hg %global pcmk_release %{?alphatag:0.}%{specversion}%{?alphatag:.%{alphatag}}%{?dist} +# Compatibility macro wrappers for legacy RPM versions that do not +# support conditional builds +%{!?bcond_without: %{expand: %%global bcond_without() %%{expand:%%%%{!?_without_%%{1}:%%%%global with_%%{1} 1}}}} +%{!?bcond_with: %{expand: %%global bcond_with() %%{expand:%%%%{?_with_%%{1}:%%%%global with_%%{1} 1}}}} +%{!?with: %{expand: %%global with() %%{expand:%%%%{?with_%%{1}:1}%%%%{!?with_%%{1}:0}}}} +%{!?without: %{expand: %%global without() %%{expand:%%%%{?with_%%{1}:0}%%%%{!?with_%%{1}:1}}}} + +# Conditionals +# Invoke "rpmbuild --without " or "rpmbuild --with " +# to disable or enable specific features +%bcond_without ais +%bcond_without heartbeat +# ESMTP is not available in RHEL, only in EPEL. Allow people to build +# the RPM without ESMTP in case they choose not to use EPEL packages +%bcond_without esmtp + Name: pacemaker Summary: Scalable High-Availability cluster resource manager Version: 1.0.7 Release: %{pcmk_release} License: GPLv2+ and LGPLv2+ Url: http://www.clusterlabs.org Group: System Environment/Daemons Source0: pacemaker.tar.bz2 BuildRoot: %(mktemp -ud %{_tmppath}/%{name}-%{version}-%{release}-XXXXXX) AutoReqProv: on Requires(pre): cluster-glue Requires: resource-agents python Conflicts: heartbeat < 2.99 %if 0%{?fedora} || 0%{?centos} > 4 || 0%{?rhel} > 4 Requires: perl(:MODULE_COMPAT_%(eval "`%{__perl} -V:version`"; echo $version)) BuildRequires: help2man libtool-ltdl-devel %endif %if 0%{?suse_version} # net-snmp-devel on SLES10 does not suck in tcpd-devel automatically BuildRequires: help2man tcpd-devel %endif # Required for core functionality BuildRequires: automake autoconf libtool pkgconfig BuildRequires: glib2-devel cluster-glue-libs-devel libxml2-devel libxslt-devel BuildRequires: pkgconfig python-devel gcc-c++ bzip2-devel gnutls-devel pam-devel # Enables optional functionality BuildRequires: ncurses-devel net-snmp-devel openssl-devel -BuildRequires: libesmtp-devel lm_sensors-devel libselinux-devel +BuildRequires: lm_sensors-devel libselinux-devel +%if %{with esmtp} +BuildRequires: libesmtp-devel +%endif -%if %with_ais_support +%if %{with ais} BuildRequires: corosynclib-devel Requires: corosync %endif -%if %with_heartbeat_support +%if %{with heartbeat} BuildRequires: heartbeat-devel heartbeat-libs Requires: heartbeat >= 3.0.0 %endif %description Pacemaker is an advanced, scalable High-Availability cluster resource manager for Linux-HA (Heartbeat) and/or OpenAIS. It supports "n-node" clusters with significant capabilities for managing resources and dependencies. It will run scripts at initialization, when machines go up or down, when related resources fail and can be configured to periodically check resource health. Available rpmbuild rebuild options: --without : heartbeat ais %package -n pacemaker-libs License: GPLv2+ and LGPLv2+ Summary: Libraries used by the Pacemaker cluster resource manager and its clients Group: System Environment/Daemons Requires: %{name} = %{version}-%{release} %description -n pacemaker-libs Pacemaker is an advanced, scalable High-Availability cluster resource manager for Linux-HA (Heartbeat) and/or OpenAIS. It supports "n-node" clusters with significant capabilities for managing resources and dependencies. It will run scripts at initialization, when machines go up or down, when related resources fail and can be configured to periodically check resource health. %package -n pacemaker-libs-devel License: GPLv2+ and LGPLv2+ Summary: Pacemaker development package Group: Development/Libraries Requires: %{name}-libs = %{version}-%{release} Requires: cluster-glue-libs-devel Obsoletes: libpacemaker3 -%if %with_ais_support +%if %{with ais} Requires: corosynclib-devel %endif -%if %with_heartbeat_support +%if %{with heartbeat} Requires: heartbeat-devel %endif %description -n pacemaker-libs-devel Headers and shared libraries for developing tools for Pacemaker. Pacemaker is an advanced, scalable High-Availability cluster resource manager for Linux-HA (Heartbeat) and/or OpenAIS. It supports "n-node" clusters with significant capabilities for managing resources and dependencies. It will run scripts at initialization, when machines go up or down, when related resources fail and can be configured to periodically check resource health. %prep %setup -q -n %{upstream_prefix}%{?upstream_version} %build ./autogen.sh # RHEL <= 5 does not support --docdir export docdir=%{pcmk_docdir} %{configure} --localstatedir=%{_var} --enable-fatal-warnings=no make %{_smp_mflags} docdir=%{pcmk_docdir} %install rm -rf %{buildroot} make install DESTDIR=%{buildroot} docdir=%{pcmk_docdir} # Scripts that need should be executable chmod a+x %{buildroot}/%{_libdir}/heartbeat/hb2openais-helper.py chmod a+x %{buildroot}/%{_datadir}/pacemaker/tests/cts/CTSlab.py chmod a+x %{buildroot}/%{_datadir}/pacemaker/tests/cts/OCFIPraTest.py chmod a+x %{buildroot}/%{_datadir}/pacemaker/tests/cts/extracttests.py # These are not actually scripts find %{buildroot} -name '*.xml' -type f -print0 | xargs -0 chmod a-x find %{buildroot} -name '*.xsl' -type f -print0 | xargs -0 chmod a-x find %{buildroot} -name '*.rng' -type f -print0 | xargs -0 chmod a-x find %{buildroot} -name '*.dtd' -type f -print0 | xargs -0 chmod a-x # Dont package static libs or compiled python find %{buildroot} -name '*.a' -type f -print0 | xargs -0 rm -f find %{buildroot} -name '*.la' -type f -print0 | xargs -0 rm -f find %{buildroot} -name '*.pyc' -type f -print0 | xargs -0 rm -f find %{buildroot} -name '*.pyo' -type f -print0 | xargs -0 rm -f # Do not package these either rm %{buildroot}/%{_libdir}/heartbeat/crm_primitive.py +%if %{with ais} rm %{buildroot}/%{_libdir}/service_crm.so +%endif %clean rm -rf %{buildroot} %post -n pacemaker-libs -p /sbin/ldconfig %postun -n pacemaker-libs -p /sbin/ldconfig %files ########################################################### %defattr(-,root,root) %exclude %{_datadir}/pacemaker/tests %{_datadir}/pacemaker %{_datadir}/snmp/mibs/PCMK-MIB.txt %{_libdir}/heartbeat/* %{_sbindir}/cibadmin %{_sbindir}/crm_attribute %{_sbindir}/crm_diff %{_sbindir}/crm_failcount %{_sbindir}/crm_master %{_sbindir}/crm_mon %{_sbindir}/crm %{_sbindir}/crm_resource %{_sbindir}/crm_standby %{_sbindir}/crm_verify %{_sbindir}/crmadmin %{_sbindir}/iso8601 %{_sbindir}/attrd_updater %{_sbindir}/ptest %{_sbindir}/crm_shadow %{_sbindir}/cibpipe %{_sbindir}/crm_node -%if %with_heartbeat_support +%if %{with heartbeat} %{_sbindir}/crm_uuid %else %exclude %{_sbindir}/crm_uuid %endif # Packaged elsewhere %exclude %{pcmk_docdir}/AUTHORS %exclude %{pcmk_docdir}/COPYING %exclude %{pcmk_docdir}/COPYING.LIB %doc %{pcmk_docdir}/crm_cli.txt %doc %{pcmk_docdir}/crm_fencing.txt %doc %{pcmk_docdir}/README.hb2openais %doc %{_mandir}/man8/*.8* %doc COPYING %doc AUTHORS %dir %attr (750, %{uname}, %{gname}) %{_var}/lib/heartbeat/crm %dir %attr (750, %{uname}, %{gname}) %{_var}/lib/pengine %dir %attr (750, %{uname}, %{gname}) %{_var}/run/crm %dir /usr/lib/ocf %dir /usr/lib/ocf/resource.d /usr/lib/ocf/resource.d/pacemaker -%if %with_ais_support +%if %{with ais} %{_libexecdir}/lcrso/pacemaker.lcrso %endif %files -n pacemaker-libs %defattr(-,root,root) %{_libdir}/libcib.so.* %{_libdir}/libcrmcommon.so.* %{_libdir}/libcrmcluster.so.* %{_libdir}/libpe_status.so.* %{_libdir}/libpe_rules.so.* %{_libdir}/libpengine.so.* %{_libdir}/libtransitioner.so.* %{_libdir}/libstonithd.so.* %doc COPYING.LIB %doc AUTHORS %files -n pacemaker-libs-devel %defattr(-,root,root) %{_includedir}/pacemaker %{_includedir}/heartbeat/fencing %{_libdir}/*.so %{_datadir}/pacemaker/tests %doc COPYING.LIB %doc AUTHORS %changelog * Tue Jan 19 2010 Andrew Beekhof - 1.0.7-2 - Rebuild for corosync 1.2.0 * Mon Jan 18 2010 Andrew Beekhof - 1.0.7-1 - Update source tarball to revision: 2eed906f43e9 (stable-1.0) tip - Statistics: Changesets: 193 Diff: 220 files changed, 15933 insertions(+), 8782 deletions(-) - Changes since 1.0.5-4 + High: PE: Bug 2213 - Ensure groups process location constraints so that clone-node-max works for cloned groups + High: PE: Bug lf#2153 - non-clones should not restart when clones stop/start on other nodes + High: PE: Bug lf#2209 - Clone ordering should be able to prevent startup of dependant clones + High: PE: Bug lf#2216 - Correctly identify the state of anonymous clones when deciding when to probe + High: PE: Bug lf#2225 - Operations that require fencing should wait for 'stonith_complete' not 'all_stopped'. + High: PE: Bug lf#2225 - Prevent clone peers from stopping while another is instance is (potentially) being fenced + High: PE: Correctly anti-colocate with a group + High: PE: Correctly unpack ordering constraints for resource sets to avoid graph loops + High: Tools: crm: load help from crm_cli.txt + High: Tools: crm: resource sets (bnc#550923) + High: Tools: crm: support for comments (LF 2221) + High: Tools: crm: support for description attribute in resources/operations (bnc#548690) + High: Tools: hb2openais: add EVMS2 CSM processing (and other changes) (bnc#548093) + High: Tools: hb2openais: do not allow empty rules, clones, or groups (LF 2215) + High: Tools: hb2openais: refuse to convert pure EVMS volumes + High: cib: Ensure the loop for login message terminates + High: cib: Finally fix reliability of receiving large messages over remote plaintext connections + High: cib: Fix remote notifications + High: cib: For remote connections, default to CRM_DAEMON_USER since thats the only one that the cib can validate the password for using PAM + High: cib: Remote plaintext - Retry sending parts of the message that did not fit the first time + High: crmd: Ensure batch-limit is correctly enforced + High: crmd: Ensure we have the latest status after a transition abort + High (bnc#547579,547582): Tools: crm: status section editing support + High: shell: Add allow-migrate as allowed meta-attribute (bnc#539968) + Medium: Build: Do not automatically add -L/lib, it could cause 64-bit arches to break + Medium: PE: Bug lf#2206 - rsc_order constraints always use score at the top level + Medium: PE: Only complain about target-role=master for non m/s resources + Medium: PE: Prevent non-multistate resources from being promoted through target-role + Medium: PE: Provide a default action for resource-set ordering + Medium: PE: Silently fix requires=fencing for stonith resources so that it can be set in op_defaults + Medium: Tools: Bug lf#2286 - Allow the shell to accept template parameters on the command line + Medium: Tools: Bug lf#2307 - Provide a way to determin the nodeid of past cluster members + Medium: Tools: crm: add update method to template apply (LF 2289) + Medium: Tools: crm: direct RA interface for ocf class resource agents (LF 2270) + Medium: Tools: crm: direct RA interface for stonith class resource agents (LF 2270) + Medium: Tools: crm: do not add score which does not exist + Medium: Tools: crm: do not consider warnings as errors (LF 2274) + Medium: Tools: crm: do not remove sets which contain id-ref attribute (LF 2304) + Medium: Tools: crm: drop empty attributes elements + Medium: Tools: crm: exclude locations when testing for pathological constraints (LF 2300) + Medium: Tools: crm: fix exit code on single shot commands + Medium: Tools: crm: fix node delete (LF 2305) + Medium: Tools: crm: implement -F (--force) option + Medium: Tools: crm: rename status to cibstatus (LF 2236) + Medium: Tools: crm: revisit configure commit + Medium: Tools: crm: stay in crm if user specified level only (LF 2286) + Medium: Tools: crm: verify changes on exit from the configure level + Medium: ais: Some clients such as gfs_controld want a cluster name, allow one to be specified in corosync.conf + Medium: cib: Clean up logic for receiving remote messages + Medium: cib: Create valid notification control messages + Medium: cib: Indicate where the remote connection came from + Medium: cib: Send password prompt to stderr so that stdout can be redirected + Medium: cts: Fix rsh handling when stdout is not required + Medium: doc: Fill in the section on removing a node from an AIS-based cluster + Medium: doc: Update the docs to reflect the 0.6/1.0 rolling upgrade problem + Medium: doc: Use Publican for docbook based documentation + Medium: fencing: stonithd: add metadata for stonithd instance attributes (and support in the shell) + Medium: fencing: stonithd: ignore case when comparing host names (LF 2292) + Medium: tools: Make crm_mon functional with remote connections + Medium: xml: Add stopped as a supported role for operations + Medium: xml: Bug bnc#552713 - Treat node unames as text fields not IDs + Medium: xml: Bug lf#2215 - Create an always-true expression for empty rules when upgrading from 0.6 * Thu Oct 29 2009 Andrew Beekhof - 1.0.5-4 - Include the fixes from CoroSync integration testing - Move the resource templates - they are not documentation - Ensure documentation is placed in a standard location - Exclude documentation that is included elsewhere in the package - Update the tarball from upstream to version ee19d8e83c2a + High: cib: Correctly clean up when both plaintext and tls remote ports are requested + High: PE: Bug bnc#515172 - Provide better defaults for lt(e) and gt(e) comparisions + High: PE: Bug lf#2197 - Allow master instances placemaker to be influenced by colocation constraints + High: PE: Make sure promote/demote pseudo actions are created correctly + High: PE: Prevent target-role from promoting more than master-max instances + High: ais: Bug lf#2199 - Prevent expected-quorum-votes from being populated with garbage + High: ais: Prevent deadlock - dont try to release IPC message if the connection failed + High: cib: For validation errors, send back the full CIB so the client can display the errors + High: cib: Prevent use-after-free for remote plaintext connections + High: crmd: Bug lf#2201 - Prevent use-of-NULL when running heartbeat * Wed Oct 13 2009 Andrew Beekhof - 1.0.5-3 - Update the tarball from upstream to version 38cd629e5c3c + High: Core: Bug lf#2169 - Allow dtd/schema validation to be disabled + High: PE: Bug lf#2106 - Not all anonymous clone children are restarted after configuration change + High: PE: Bug lf#2170 - stop-all-resources option had no effect + High: PE: Bug lf#2171 - Prevent groups from starting if they depend on a complex resource which can not + High: PE: Disable resource management if stonith-enabled=true and no stonith resources are defined + High: PE: do not include master score if it would prevent allocation + High: ais: Avoid excessive load by checking for dead children every 1s (instead of 100ms) + High: ais: Bug rh#525589 - Prevent shutdown deadlocks when running on CoroSync + High: ais: Gracefully handle changes to the AIS nodeid + High: crmd: Bug bnc#527530 - Wait for the transition to complete before leaving S_TRANSITION_ENGINE + High: crmd: Prevent use-after-free with LOG_DEBUG_3 + Medium: xml: Mask the "symmetrical" attribute on rsc_colocation constraints (bnc#540672) + Medium (bnc#520707): Tools: crm: new templates ocfs2 and clvm + Medium: Build: Invert the disable ais/heartbeat logic so that --without (ais|heartbeat) is available to rpmbuild + Medium: PE: Bug lf#2178 - Indicate unmanaged clones + Medium: PE: Bug lf#2180 - Include node information for all failed ops + Medium: PE: Bug lf#2189 - Incorrect error message when unpacking simple ordering constraint + Medium: PE: Correctly log resources that would like to start but can not + Medium: PE: Stop ptest from logging to syslog + Medium: ais: Include version details in plugin name + Medium: crmd: Requery the resource metadata after every start operation * Fri Aug 21 2009 Tomas Mraz - 1.0.5-2.1 - rebuilt with new openssl * Wed Aug 19 2009 Andrew Beekhof - 1.0.5-2 - Add versioned perl dependancy as specified by https://fedoraproject.org/wiki/Packaging/Perl#Packages_that_link_to_libperl - No longer remove RPATH data, it prevents us finding libperl.so and no other libraries were being hardcoded - Compile in support for heartbeat - Conditionally add heartbeat-devel and corosynclib-devel to the -devel requirements depending on which stacks are supported * Mon Aug 17 2009 Andrew Beekhof - 1.0.5-1 - Add dependancy on resource-agents - Use the version of the configure macro that supplies --prefix, --libdir, etc - Update the tarball from upstream to version 462f1569a437 (Pacemaker 1.0.5 final) + High: Tools: crm_resource - Advertise --move instead of --migrate + Medium: Extra: New node connectivity RA that uses system ping and attrd_updater + Medium: crmd: Note that dc-deadtime can be used to mask the brokeness of some switches * Tue Aug 11 2009 Ville Skyttä - 1.0.5-0.7.c9120a53a6ae.hg - Use bzipped upstream tarball. * Wed Jul 29 2009 Andrew Beekhof - 1.0.5-0.6.c9120a53a6ae.hg - Add back missing build auto* dependancies - Minor cleanups to the install directive * Tue Jul 28 2009 Andrew Beekhof - 1.0.5-0.5.c9120a53a6ae.hg - Add a leading zero to the revision when alphatag is used * Tue Jul 28 2009 Andrew Beekhof - 1.0.5-0.4.c9120a53a6ae.hg - Incorporate the feedback from the cluster-glue review - Realistically, the version is a 1.0.5 pre-release - Use the global directive instead of define for variables - Use the haclient/hacluster group/user instead of daemon - Use the _configure macro - Fix install dependancies * Fri Jul 24 2009 Andrew Beekhof - 1.0.4-3 - Initial Fedora checkin - Include an AUTHORS and license file in each package - Change the library package name to pacemaker-libs to be more Fedora compliant - Remove execute permissions from xml related files - Reference the new cluster-glue devel package name - Update the tarball from upstream to version c9120a53a6ae + High: PE: Only prevent migration if the clone dependancy is stopping/starting on the target node + High: PE: Bug 2160 - Dont shuffle clones due to colocation + High: PE: New implementation of the resource migration (not stop/start) logic + Medium: Tools: crm_resource - Prevent use-of-NULL by requiring a resource name for the -A and -a options + Medium: PE: Prevent use-of-NULL in find_first_action() * Tue Jul 14 2009 Andrew Beekhof - 1.0.4-2 - Reference authors from the project AUTHORS file instead of listing in description - Change Source0 to reference the Mercurial repo - Cleaned up the summaries and descriptions - Incorporate the results of Fedora package self-review * Thu Jun 04 2009 Andrew Beekhof - 1.0.4-1 - Update source tarball to revision: 1d87d3e0fc7f (stable-1.0) - Statistics: Changesets: 209 Diff: 266 files changed, 12010 insertions(+), 8276 deletions(-) - Changes since Pacemaker-1.0.3 + High (bnc#488291): ais: do not rely on byte endianness on ptr cast + High (bnc#507255): Tools: crm: delete rsc/op_defaults (these meta_attributes are killing me) + High (bnc#507255): Tools: crm: import properly rsc/op_defaults + High (LF 2114): Tools: crm: add support for operation instance attributes + High: ais: Bug lf#2126 - Messages replies cannot be routed to transient clients + High: ais: Fix compilation for the latest Corosync API (v1719) + High: attrd: Do not perform all updates as complete refreshes + High: cib: Fix huge memory leak affecting heartbeat-based clusters + High: Core: Allow xpath queries to match attributes + High: Core: Generate the help text directly from a tool options struct + High: Core: Handle differences in 0.6 messaging format + High: crmd: Bug lf#2120 - All transient node attribute updates need to go via attrd + High: crmd: Correctly calculate how long an FSA action took to avoid spamming the logs with errors + High: crmd: Fix another large memory leak affecting Heartbeat based clusters + High: lha: Restore compatability with older versions + High: PE: Bug bnc#495687 - Filesystem is not notified of successful STONITH under some conditions + High: PE: Make running a cluster with STONITH enabled but no STONITH resources an error and provide details on resolutions + High: PE: Prevent use-ofNULL when using resource ordering sets + High: PE: Provide inter-notification ordering guarantees + High: PE: Rewrite the notification code to be understanable and extendable + High: Tools: attrd - Prevent race condition resulting in the cluster forgetting the node wishes to shut down + High: Tools: crm: regression tests + High: Tools: crm_mon - Fix smtp notifications + High: Tools: crm_resource - Repair the ability to query meta attributes + Low Build: Bug lf#2105 - Debian package should contain pacemaker doc and crm templates + Medium (bnc#507255): Tools: crm: handle empty rsc/op_defaults properly + Medium (bnc#507255): Tools: crm: use the right obj_type when creating objects from xml nodes + Medium (LF 2107): Tools: crm: revisit exit codes in configure + Medium: cib: Do not bother validating updates that only affect the status section + Medium: Core: Include supported stacks in version information + Medium: crmd: Record in the CIB, the cluster infrastructure being used + Medium: cts: Do not combine crm_standby arguments - the wrapper ca not process them + Medium: cts: Fix the CIBAusdit class + Medium: Extra: Refresh showscores script from Dominik + Medium: PE: Build a statically linked version of ptest + Medium: PE: Correctly log the actions for resources that are being recovered + Medium: PE: Correctly log the occurance of promotion events + Medium: PE: Implememt node health based on a patch from Mark Hamzy + Medium: Tools: Add examples to help text outputs + Medium: Tools: crm: catch syntax errors for configure load + Medium: Tools: crm: implement erasing nodes in configure erase + Medium: Tools: crm: work with parents only when managing xml objects + Medium: Tools: crm_mon - Add option to run custom notification program on resource operations (Patch by Dominik Klein) + Medium: Tools: crm_resource - Allow --cleanup to function on complex resources and cluster-wide + Medium: Tools: haresource2cib.py - Patch from horms to fix conversion error + Medium: Tools: Include stack information in crm_mon output + Medium: Tools: Two new options (--stack,--constraints) to crm_resource for querying how a resource is configured * Wed Apr 08 2009 Andrew Beekhof - 1.0.3-1 - Update source tarball to revision: b133b3f19797 (stable-1.0) tip - Statistics: Changesets: 383 Diff: 329 files changed, 15471 insertions(+), 15119 deletions(-) - Changes since Pacemaker-1.0.2 + Added tag SLE11-HAE-GMC for changeset 9196be9830c2 + High: ais plugin: Fix quorum calculation (bnc#487003) + High: ais: Another memory fix leak in error path + High: ais: Bug bnc#482847, bnc#482905 - Force a clean exit of OpenAIS once Pacemaker has finished unloading + High: ais: Bug bnc#486858 - Fix update_member() to prevent spamming clients with membership events containing no changes + High: ais: Centralize all quorum calculations in the ais plugin and allow expected votes to be configured int he cib + High: ais: Correctly handle a return value of zero from openais_dispatch_recv() + High: ais: Disable logging to a file + High: ais: Fix memory leak in error path + High: ais: IPC messages are only in scope until a response is sent + High: All signal handlers used with CL_SIGNAL() need to be as minimal as possible + High: cib: Bug bnc#482885 - Simplify CIB disk-writes to prevent data loss. Required a change to the backup filename format + High: cib: crmd: Revert part of 9782ab035003. Complex shutdown routines need G_main_add_SignalHandler to avoid race coditions + High: crm: Avoid infinite loop during crm configure edit (bnc#480327) + High: crmd: Avoid a race condition by waiting for the attrd update to trigger a transition automatically + High: crmd: Bug bnc#480977 - Prevent extra, partial, shutdown when a node restarts too quickly + High: crmd: Bug bnc#480977 - Prevent extra, partial, shutdown when a node restarts too quickly (verified) + High: crmd: Bug bnc#489063 - Ensure the DC is always unset after we 'loose' an election + High: crmd: Bug BSC#479543 - Correctly find the migration source for timed out migrate_from actions + High: crmd: Call crm_peer_init() before we start the FSA - prevents a race condition when used with Heartbeat + High: crmd: Erasing the status section should not be forced to the local node + High: crmd: Fix memory leak in cib notication processing code + High: crmd: Fix memory leak in transition graph processing + High: crmd: Fix memory leaks found by valgrind + High: crmd: More memory leaks fixes found by valgrind + High: fencing: stonithd: is_heartbeat_cluster is a no-no if there is no heartbeat support + High: PE: Bug bnc#466788 - Exclude nodes that can not run resources + High: PE: Bug bnc#466788 - Make colocation based on node attributes work + High: PE: Bug BNC#478687 - Do not crash when clone-max is 0 + High: PE: Bug bnc#488721 - Fix id-ref expansion for clones, the doc-root for clone children is not the cib root + High: PE: Bug bnc#490418 - Correctly determine node state for nodes wishing to be terminated + High: PE: Bug LF#2087 - Correctly parse the state of anonymous clones that have multiple instances on a given node + High: PE: Bug lf#2089 - Meta attributes are not inherited by clone children + High: PE: Bug lf#2091 - Correctly restart modified resources that were found active by a probe + High: PE: Bug lf#2094 - Fix probe ordering for cloned groups + High: PE: Bug LF:2075 - Fix large pingd memory leaks + High: PE: Correctly attach orphaned clone children to their parent + High: PE: Correctly handle terminate node attributes that are set to the output from time() + High: PE: Ensure orphaned clone members are hooked up to the parent when clone-max=0 + High: PE: Fix memory leak in LogActions + High: PE: Fix the determination of whether a group is active + High: PE: Look up the correct promotion preference for anonymous masters + High: PE: Simplify handling of start failures by changing the default migration-threshold to INFINITY + High: PE: The ordered option for clones no longer causes extra start/stop operations + High: RA: Bug bnc#490641 - Shut down dlm_controld with -TERM instead of -KILL + High: RA: pingd: Set default ping interval to 1 instead of 0 seconds + High: Resources: pingd - Correctly tell the ping daemon to shut down + High: Tools: Bug bnc#483365 - Ensure the command from cluster_test includes a value for --log-facility + High: Tools: cli: fix and improve delete command + High: Tools: crm: add and implement templates + High: Tools: crm: add support for command aliases and some common commands (i.e. cd,exit) + High: Tools: crm: create top configuration nodes if they are missing + High: Tools: crm: fix parsing attributes for rules (broken by the previous changeset) + High: Tools: crm: new ra set of commands + High: Tools: crm: resource agents information management + High: Tools: crm: rsc/op_defaults + High: Tools: crm: support for no value attribute in nvpairs + High: Tools: crm: the new configure monitor command + High: Tools: crm: the new configure node command + High: Tools: crm_mon - Prevent use-of-NULL when summarizing an orphan + High: Tools: hb2openais: create clvmd clone for respawn evmsd in ha.cf + High: Tools: hb2openais: fix a serious recursion bug in xml node processing + High: Tools: hb2openais: fix ocfs2 processing + High: Tools: pingd - prevent double free of getaddrinfo() output in error path + High: Tools: The default re-ping interval for pingd should be 1s not 1ms + Medium (bnc#479049): Tools: crm: add validation of resource type for the configure primitive command + Medium (bnc#479050): Tools: crm: add help for RA parameters in tab completion + Medium (bnc#479050): Tools: crm: add tab completion for primitive params/meta/op + Medium (bnc#479050): Tools: crm: reimplement cluster properties completion + Medium (bnc#486968): Tools: crm: listnodes function requires no parameters (do not mix completion with other stuff) + Medium: ais: Remove the ugly hack for dampening AIS membership changes + Medium: cib: Fix memory leaks by using mainloop_add_signal + Medium: cib: Move more logging to the debug level (was info) + Medium: cib: Overhaul the processing of synchronous replies + Medium: Core: Add library functions for instructing the cluster to terminate nodes + Medium: crmd: Add new expected-quorum-votes option + Medium: crmd: Allow up to 5 retires when an attrd update fails + Medium: crmd: Automatically detect and use new values for crm_config options + Medium: crmd: Bug bnc#490426 - Escalated shutdowns stall when there are pending resource operations + Medium: crmd: Clean up and optimize the DC election algorithm + Medium: crmd: Fix memory leak in shutdown + Medium: crmd: Fix memory leaks spotted by Valgrind + Medium: crmd: Ingore join messages from hosts other than our DC + Medium: crmd: Limit the scope of resource updates to the status section + Medium: crmd: Prevent the crmd from being respawned if its told to shut down when it did not ask to be + Medium: crmd: Re-check the election status after membership events + Medium: crmd: Send resource updates via the local CIB during elections + Medium: PE: Bug bnc#491441 - crm_mon does not display operations returning 'uninstalled' correctly + Medium: PE: Bug lf#2101 - For location constraints, role=Slave is equivalent to role=Started + Medium: PE: Clean up the API - removed ->children() and renamed ->find_child() to fine_rsc() + Medium: PE: Compress the display of healthy anonymous clones + Medium: PE: Correctly log the actions for resources that are being recovered + Medium: PE: Determin a promotion score for complex resources + Medium: PE: Ensure clones always have a value for globally-unique + Medium: PE: Prevent orphan clones from being allocated + Medium: RA: controld: Return proper exit code for stop op. + Medium: Tools: Bug bnc#482558 - Fix logging test in cluster_test + Medium: Tools: Bug bnc#482828 - Fix quoting in cluster_test logging setup + Medium: Tools: Bug bnc#482840 - Include directory path to CTSlab.py + Medium: Tools: crm: add more user input checks + Medium: Tools: crm: do not check resource status of we are working with a shadow + Medium: Tools: crm: fix id-refs and allow reference to top objects (i.e. primitive) + Medium: Tools: crm: ignore comments in the CIB + Medium: Tools: crm: multiple column output would not work with small lists + Medium: Tools: crm: refuse to delete running resources + Medium: Tools: crm: rudimentary if-else for templates + Medium: Tools: crm: Start/stop clones via target-role. + Medium: Tools: crm_mon - Compress the node status for healthy and offline nodes + Medium: Tools: crm_shadow - Return 0/cib_ok when --create-empty succeeds + Medium: Tools: crm_shadow - Support -e, the short form of --create-empty + Medium: Tools: Make attrd quieter + Medium: Tools: pingd - Avoid using various clplumbing functions as they seem to leak + Medium: Tools: Reduce pingd logging * Mon Feb 16 2009 Andrew Beekhof - 1.0.2-1 - Update source tarball to revision: d232d19daeb9 (stable-1.0) tip - Statistics: Changesets: 441 Diff: 639 files changed, 20871 insertions(+), 21594 deletions(-) - Changes since Pacemaker-1.0.1 + High (bnc#450815): Tools: crm cli: do not generate id for the operations tag + High: ais: Add support for the new AIS IPC layer + High: ais: Always set header.error to the correct default: SA_AIS_OK + High: ais: Bug BNC#456243 - Ensure the membership cache always contains an entry for the local node + High: ais: Bug BNC:456208 - Prevent deadlocks by not logging in the child process before exec() + High: ais: By default, disable supprt for the WIP openais IPC patch + High: ais: Detect and handle situations where ais and the crm disagree on the node name + High: ais: Ensure crm_peer_seq is updated after a membership update + High: ais: Make sure all IPC header fields are set to sane defaults + High: ais: Repair and streamline service load now that whitetank startup functions correctly + High: build: create and install doc files + High: cib: Allow clients without mainloop to connect to the cib + High: cib: CID:18 - Fix use-of-NULL in cib_perform_op + High: cib: CID:18 - Repair errors introduced in b5a18704477b - Fix use-of-NULL in cib_perform_op + High: cib: Ensure diffs contain the correct values of admin_epoch + High: cib: Fix four moderately sized memory leaks detected by Valgrind + High: Core: CID:10 - Prevent indexing into an array of schemas with a negative value + High: Core: CID:13 - Fix memory leak in log_data_element + High: Core: CID:15 - Fix memory leak in crm_get_peer + High: Core: CID:6 - Fix use-of-NULL in copy_ha_msg_input + High: Core: Fix crash in the membership code preventing node shutdown + High: Core: Fix more memory leaks foudn by valgrind + High: Core: Prevent unterminated strings after decompression + High: crmd: Bug BNC:467995 - Delay marking STONITH operations complete until STONITH tells us so + High: crmd: Bug LF:1962 - Do not NACK peers because they are not (yet) in our membership. Just ignore them. + High: crmd: Bug LF:2010 - Ensure fencing cib updates create the node_state entry if needed to preent re-fencing during cluster startup + High: crmd: Correctly handle reconnections to attrd + High: crmd: Ensure updates for lost migrate operations indicate which node it tried to migrating to + High: crmd: If there are no nodes to finalize, start an election. + High: crmd: If there are no nodes to welcome, start an election. + High: crmd: Prevent node attribute loss by detecting attrd disconnections immediately + High: crmd: Prevent node re-probe loops by ensuring manditory actions always complete + High: PE: Bug 2005 - Fix startup ordering of cloned stonith groups + High: PE: Bug 2006 - Correctly reprobe cloned groups + High: PE: Bug BNC:465484 - Fix the no-quorum-policy=suicide option + High: PE: Bug LF:1996 - Correctly process disabled monitor operations + High: PE: CID:19 - Fix use-of-NULL in determine_online_status + High: PE: Clones now default to globally-unique=false + High: PE: Correctly calculate the number of available nodes for the clone to use + High: PE: Only shoot online nodes with no-quorum-policy=suicide + High: PE: Prevent on-fail settings being ignored after a resource is successfully stopped + High: PE: Prevent use-of-NULL for failed migrate actions in process_rsc_state() + High: PE: Remove an optimization for the terminate node attribute that caused the cluster to block indefinitly + High: PE: Repar the ability to colocate based on node attributes other than uname + High: PE: Start the correct monitor operation for unmanaged masters + High: stonith: CID:3 - Fix another case of exceptionally poor error handling by the original stonith developers + High: stonith: CID:5 - Checking for NULL and then dereferencing it anyway is an interesting approach to error handling + High: stonithd: Sending IPC to the cluster is a privileged operation + High: stonithd: wrong checks for shmid (0 is a valid id) + High: Tools: attrd - Correctly determine when an attribute has stopped changing and should be committed to the CIB + High: Tools: Bug 2003 - pingd does not correctly detect failures when the interface is down + High: Tools: Bug 2003 - pingd does not correctly handle node-down events on multi-NIC systems + High: Tools: Bug 2021 - pingd does not detect sequence wrapping correctly, incorrectly reports nodes offline + High: Tools: Bug BNC:468066 - Do not use the result of uname() when its no longer in scope + High: Tools: Bug BNC:473265 - crm_resource -L dumps core + High: Tools: Bug LF:2001 - Transient node attributes should be set via attrd + High: Tools: Bug LF:2036 - crm_resource cannot set/get parameters for cloned resources + High: Tools: Bug LF:2046 - Node attribute updates are lost because attrd can take too long to start + High: Tools: Cause the correct clone instance to be failed with crm_resource -F + High: Tools: cluster_test - Allow the user to select a stack and fix CTS invocation + High: Tools: crm cli: allow rename only if the resource is stopped + High: Tools: crm cli: catch system errors on file operations + High: Tools: crm cli: completion for ids in configure + High: Tools: crm cli: drop '-rsc' from attributes for order constraint + High: Tools: crm cli: exit with an appropriate exit code + High: Tools: crm cli: fix wrong order of action and resource in order constraint + High: Tools: crm cli: fox wrong exit code + High: Tools: crm cli: improve handling of cib attributes + High: Tools: crm cli: new command: configure rename + High: Tools: crm cli: new command: configure upgrade + High: Tools: crm cli: new command: node delete + High: Tools: crm cli: prevent key errors on missing cib attributes + High: Tools: crm cli: print long help for help topics + High: Tools: crm cli: return on syntax error when parsing score + High: Tools: crm cli: rsc_location can be without nvpairs + High: Tools: crm cli: short node preference location constraint + High: Tools: crm cli: sometimes, on errors, level would change on single shot use + High: Tools: crm cli: syntax: drop a bunch of commas (remains of help tables conversion) + High: Tools: crm cli: verify user input for sanity + High: Tools: crm: find expressions within rules (do not always skip xml nodes due to used id) + High: Tools: crm_master should not define a set id now that attrd is used. Defining one can break lookups + High: Tools: crm_mon Use the OID assigned to the project by IANA for SNMP traps + Medium (bnc#445622): Tools: crm cli: improve the node show command and drop node status + Medium (LF 2009): stonithd: improve timeouts for remote fencing + Medium: ais: Allow dead peers to be removed from membership calculations + Medium: ais: Pass node deletion events on to clients + Medium: ais: Sanitize ipc usage + Medium: ais: Supply the node uname in addtion to the id + Medium: Build: Clean up configure to ensure NON_FATAL_CFLAGS is consistent with CFLAGS (ie. includes -g) + Medium: Build: Install cluster_test + Medium: Build: Use more restrictive CFLAGS and fix the resulting errors + Medium: cib: CID:20 - Fix potential use-after-free in cib_native_signon + Medium: Core: Bug BNC:474727 - Set a maximum time to wait for IPC messages + Medium: Core: CID:12 - Fix memory leak in decode_transition_magic error path + Medium: Core: CID:14 - Fix memory leak in calculate_xml_digest error path + Medium: Core: CID:16 - Fix memory leak in date_to_string error path + Medium: Core: Try to track down the cause of XML parsing errors + Medium: crmd: Bug BNC:472473 - Do not wait excessive amounts of time for lost actions + Medium: crmd: Bug BNC:472473 - Reduce the transition timeout to action_timeout+network_delay + Medium: crmd: Do not fast-track the processing of LRM refreshes when there are pending actions. + Medium: crmd: do_dc_join_filter_offer - Check the 'join' message is for the current instance before deciding to NACK peers + Medium: crmd: Find option values without having to do a config upgrade + Medium: crmd: Implement shutdown using a transient node attribute + Medium: crmd: Update the crmd options to use dashes instead of underscores + Medium: cts: Add 'cluster reattach' to the suite of automated regression tests + Medium: cts: cluster_test - Make some usability enhancements + Medium: CTS: cluster_test - suggest a valid port number + Medium: CTS: Fix python import order + Medium: cts: Implement an automated SplitBrain test + Medium: CTS: Remove references to deleted classes + Medium: Extra: Resources - Use HA_VARRUN instead of HA_RSCTMP for state files as Heartbeat removes HA_RSCTMP at startup + Medium: HB: Bug 1933 - Fake crmd_client_status_callback() calls because HB does not provide them for already running processes + Medium: PE: CID:17 - Fix memory leak in find_actions_by_task error path + Medium: PE: CID:7,8 - Prevent hypothetical use-of-NULL in LogActions + Medium: PE: Defer logging the actions performed on a resource until we have processed ordering constraints + Medium: PE: Remove the symmetrical attribute of colocation constraints + Medium: Resources: pingd - fix the meta defaults + Medium: Resources: Stateful - Add missing meta defaults + Medium: stonithd: exit if we the pid file cannot be locked + Medium: Tools: Allow attrd clients to specify the ID the attribute should be created with + Medium: Tools: attrd - Allow attribute updates to be performed from a hosts peer + Medium: Tools: Bug LF:1994 - Clean up crm_verify return codes + Medium: Tools: Change the pingd defaults to ping hosts once every second (instead of 5 times every 10 seconds) + Medium: Tools: cibmin - Detect resource operations with a view to providing email/snmp/cim notification + Medium: Tools: crm cli: add back symmetrical for order constraints + Medium: Tools: crm cli: generate role in location when converting from xml + Medium: Tools: crm cli: handle shlex exceptions + Medium: Tools: crm cli: keep order of help topics + Medium: Tools: crm cli: refine completion for ids in configure + Medium: Tools: crm cli: replace inf with INFINITY + Medium: Tools: crm cli: streamline cib load and parsing + Medium: Tools: crm cli: supply provider only for ocf class primitives + Medium: Tools: crm_mon - Add support for sending mail notifications of resource events + Medium: Tools: crm_mon - Include the DC version in status summary + Medium: Tools: crm_mon - Sanitize startup and option processing + Medium: Tools: crm_mon - switch to event-driven updates and add support for sending snmp traps + Medium: Tools: crm_shadow - Replace the --locate option with the saner --edit + Medium: Tools: hb2openais: do not remove Evmsd resources, but replace them with clvmd + Medium: Tools: hb2openais: replace crmadmin with crm_mon + Medium: Tools: hb2openais: replace the lsb class with ocf for o2cb + Medium: Tools: hb2openais: reuse code + Medium: Tools: LF:2029 - Display an error if crm_resource is used to reset the operation history of non-primitive resources + Medium: Tools: Make pingd resilient to attrd failures + Medium: Tools: pingd - fix the command line switches + Medium: Tools: Rename ccm_tool to crm_node * Tue Nov 18 2008 Andrew Beekhof - 1.0.1-1 - Update source tarball to revision: 6fc5ce8302ab (stable-1.0) tip - Statistics: Changesets: 170 Diff: 816 files changed, 7633 insertions(+), 6286 deletions(-) - Changes since Pacemaker-1.0.1 + High: ais: Allow the crmd to get callbacks whenever a node state changes + High: ais: Create an option for starting the mgmtd daemon automatically + High: ais: Ensure HA_RSCTMP exists for use by resource agents + High: ais: Hook up the openais.conf config logging options + High: ais: Zero out the PID of disconnecting clients + High: cib: Ensure global updates cause a disk write when appropriate + High: Core: Add an extra snaity check to getXpathResults() to prevent segfaults + High: Core: Do not redefine __FUNCTION__ unnecessarily + High: Core: Repair the ability to have comments in the configuration + High: crmd: Bug:1975 - crmd should wait indefinitely for stonith operations to complete + High: crmd: Ensure PE processing does not occur for all error cases in do_pe_invoke_callback + High: crmd: Requests to the CIB should cause any prior PE calculations to be ignored + High: heartbeat: Wait for membership 'up' events before removing stale node status data + High: PE: Bug LF:1988 - Ensure recurring operations always have the correct target-rc set + High: PE: Bug LF:1988 - For unmanaged resources we need to skip the usual can_run_resources() checks + High: PE: Ensure the terminate node attribute is handled correctly + High: PE: Fix optional colocation + High: PE: Improve up the detection of 'new' nodes joining the cluster + High: PE: Prevent assert failures in master_color() by ensuring unmanaged masters are always reallocated to their current location + High: Tools: crm cli: parser: return False on syntax error and None for comments + High: Tools: crm cli: unify template and edit commands + High: Tools: crm_shadow - Show more line number information after validation failures + High: Tools: hb2openais: add option to upgrade the CIB to v3.0 + High: Tools: hb2openais: add U option to getopts and update usage + High: Tools: hb2openais: backup improved and multiple fixes + High: Tools: hb2openais: fix class/provider reversal + High: Tools: hb2openais: fix testing + High: Tools: hb2openais: move the CIB update to the end + High: Tools: hb2openais: update logging and set logfile appropriately + High: Tools: LF:1969 - Attrd never sets any properties in the cib + High: Tools: Make attrd functional on OpenAIS + Medium: ais: Hook up the options for specifying the expected number of nodes and total quorum votes + Medium: ais: Look for pacemaker options inside the service block with 'name: pacemaker' instead of creating an addtional configuration block + Medium: ais: Provide better feedback when nodes change nodeids (in openais.conf) + Medium: cib: Always store cib contents on disk with num_updates=0 + Medium: cib: Ensure remote access ports are cleaned up on shutdown + Medium: crmd: Detect deleted resource operations automatically + Medium: crmd: Erase a nodes resource operations and transient attributes after a successful STONITH + Medium: crmd: Find a more appropriate place to update quorum and refresh attrd attributes + Medium: crmd: Fix the handling of unexpected PE exits to ensure the current CIB is stored + Medium: crmd: Fix the recording of pending operations in the CIB + Medium: crmd: Initiate an attrd refresh _after_ the status section has been fully repopulated + Medium: crmd: Only the DC should update quorum in an openais cluster + Medium: Ensure meta attributes are used consistantly + Medium: PE: Allow group and clone level resource attributes + Medium: PE: Bug N:437719 - Ensure scores from colocated resources count when allocating groups + Medium: PE: Prevent lsb scripts from being used in globally unique clones + Medium: PE: Make a best-effort guess at a migration threshold for people with 0.6 configs + Medium: Resources: controld - ensure we are part of a clone with globally_unique=false + Medium: Tools: attrd - Automatically refresh all attributes after a CIB replace operation + Medium: Tools: Bug LF:1985 - crm_mon - Correctly process failed cib queries to allow reconnection after cluster restarts + Medium: Tools: Bug LF:1987 - crm_verify incorrectly warns of configuration upgrades for the most recent version + Medium: Tools: crm (bnc#441028): check for key error in attributes management + Medium: Tools: crm_mon - display the meaning of the operation rc code instead of the status + Medium: Tools: crm_mon - Fix the display of timing data + Medium: Tools: crm_verify - check that we are being asked to validate a complete config + Medium: xml: Relax the restriction on the contents of rsc_locaiton.node * Thu Oct 16 2008 Andrew Beekhof - 1.0.0-1 - Update source tarball to revision: 388654dfef8f tip - Statistics: Changesets: 261 Diff: 3021 files changed, 244985 insertions(+), 111596 deletions(-) - Changes since f805e1b30103 + High: add the crm cli program + High: ais: Move the service id definition to a common location and make sure it is always used + High: build: rename hb2openais.sh to .in and replace paths with vars + High: cib: Implement --create for crm_shadow + High: cib: Remove dead files + High: Core: Allow the expected number of quorum votes to be configrable + High: Core: cl_malloc and friends were removed from Heartbeat + High: Core: Only call xmlCleanupParser() if we parsed anything. Doing so unconditionally seems to cause a segfault + High: hb2openais.sh: improve pingd handling; several bugs fixed + High: hb2openais: fix clone creation; replace EVMS strings + High: new hb2openais.sh conversion script + High: PE: Bug LF:1950 - Ensure the current values for all notification variables are always set (even if empty) + High: PE: Bug LF:1955 - Ensure unmanaged masters are unconditionally repromoted to ensure they are monitored correctly. + High: PE: Bug LF:1955 - Fix another case of filtering causing unmanaged master failures + High: PE: Bug LF:1955 - Umanaged mode prevents master resources from being allocated correctly + High: PE: Bug N:420538 - Anit-colocation caused a positive node preference + High: PE: Correctly handle unmanaged resources to prevent them from being started elsewhere + High: PE: crm_resource - Fix the --migrate command + High: PE: MAke stonith-enabled default to true and warn if no STONITH resources are found + High: PE: Make sure orphaned clone children are created correctly + High: PE: Monitors for unmanaged resources do not need to wait for start/promote/demote actions to complete + High: stonithd (LF 1951): fix remote stonith operations + High: stonithd: fix handling of timeouts + High: stonithd: fix logic for stonith resource priorities + High: stonithd: implement the fence-timeout instance attribute + High: stonithd: initialize value before reading fence-timeout + High: stonithd: set timeouts for fencing ops to the timeout of the start op + High: stonithd: stonith rsc priorities (new feature) + High: Tools: Add hb2openais - a tool for upgrading a Heartbeat cluster to use OpenAIS instead + High: Tools: crm_verify - clean up the upgrade logic to prevent crash on invalid configurations + High: Tools: Make pingd functional on Linux + High: Update version numbers for 1.0 candidates + Medium: ais: Add support for a synchronous call to retrieve the nodes nodeid + Medium: ais: Use the agreed service number + Medium: Build: Reliably detect heartbeat libraries during configure + Medium: Build: Supply prototypes for libreplace functions when needed + Medium: Build: Teach configure how to find corosync + Medium: Core: Provide better feedback if Pacemaker is started by a stack it does not support + Medium: crmd: Avoid calling GHashTable functions with NULL + Medium: crmd: Delay raising I_ERROR when the PE exits until we have had a chance to save the current CIB + Medium: crmd: Hook up the stonith-timeout option to stonithd + Medium: crmd: Prevent potential use-of-NULL in global_timer_callback + Medium: crmd: Rationalize the logging of graph aborts + Medium: PE: Add a stonith_timeout option and remove new options that are better set in rsc_defaults + Medium: PE: Allow external entities to ask for a node to be shot by creating a terminate=true transient node attribute + Medium: PE: Bug LF:1950 - Notifications do not contain all documented resource state fields + Medium: PE: Bug N:417585 - Do not restart group children whos individual score drops below zero + Medium: PE: Detect clients that disconnect before receiving their reply + Medium: PE: Implement a true maintenance mode + Medium: PE: Implement on-fail=standby for NTT. Derived from a patch by Satomi TANIGUCHI + Medium: PE: Print the correct message when stonith is disabled + Medium: PE: ptest - check the input is valid before proceeding + Medium: PE: Revert group stickiness to the 'old way' + Medium: PE: Use the correct attribute for action 'requires' (was prereq) + Medium: stonithd: Fix compilation without full heartbeat install + Medium: stonithd: exit with better code on empty host list + Medium: tools: Add a new regression test for CLI tools + Medium: tools: crm_resource - return with non-zero when a resource migration command is invalid + Medium: tools: crm_shadow - Allow the admin to start with an empty CIB (and no cluster connection) + Medium: xml: pacemaker-0.7 is now an alias for the 1.0 schema * Mon Sep 22 2008 Andrew Beekhof - 0.7.3-1 - Update source tarball to revision: 33e677ab7764+ tip - Statistics: Changesets: 133 Diff: 89 files changed, 7492 insertions(+), 1125 deletions(-) - Changes since f805e1b30103 + High: Tools: add the crm cli program + High: Core: cl_malloc and friends were removed from Heartbeat + High: Core: Only call xmlCleanupParser() if we parsed anything. Doing so unconditionally seems to cause a segfault + High: new hb2openais.sh conversion script + High: PE: Bug LF:1950 - Ensure the current values for all notification variables are always set (even if empty) + High: PE: Bug LF:1955 - Ensure unmanaged masters are unconditionally repromoted to ensure they are monitored correctly. + High: PE: Bug LF:1955 - Fix another case of filtering causing unmanaged master failures + High: PE: Bug LF:1955 - Umanaged mode prevents master resources from being allocated correctly + High: PE: Bug N:420538 - Anit-colocation caused a positive node preference + High: PE: Correctly handle unmanaged resources to prevent them from being started elsewhere + High: PE: crm_resource - Fix the --migrate command + High: PE: MAke stonith-enabled default to true and warn if no STONITH resources are found + High: PE: Make sure orphaned clone children are created correctly + High: PE: Monitors for unmanaged resources do not need to wait for start/promote/demote actions to complete + High: stonithd (LF 1951): fix remote stonith operations + High: Tools: crm_verify - clean up the upgrade logic to prevent crash on invalid configurations + Medium: ais: Add support for a synchronous call to retrieve the nodes nodeid + Medium: ais: Use the agreed service number + Medium: PE: Allow external entities to ask for a node to be shot by creating a terminate=true transient node attribute + Medium: PE: Bug LF:1950 - Notifications do not contain all documented resource state fields + Medium: PE: Bug N:417585 - Do not restart group children whos individual score drops below zero + Medium: PE: Implement a true maintenance mode + Medium: PE: Print the correct message when stonith is disabled + Medium: stonithd: exit with better code on empty host list + Medium: xml: pacemaker-0.7 is now an alias for the 1.0 schema * Wed Aug 20 2008 Andrew Beekhof - 0.7.1-1 - Update source tarball to revision: f805e1b30103+ tip - Statistics: Changesets: 184 Diff: 513 files changed, 43408 insertions(+), 43783 deletions(-) - Changes since 0.7.0-19 + Fix compilation when GNUTLS isnt found + High: admin: Fix use-after-free in crm_mon + High: Build: Remove testing code that prevented heartbeat-only builds + High: cib: Use single quotes so that the xpath queries for nvpairs will succeed + High: crmd: Always connect to stonithd when the TE starts and ensure we notice if it dies + High: crmd: Correctly handle a dead PE process + High: crmd: Make sure async-failures cause the failcount to be incrimented + High: PE: Bug LF:1941 - Handle failed clone instance probes when clone-max < #nodes + High: PE: Parse resource ordering sets correctly + High: PE: Prevent use-of-NULL - order->rsc_rh will not always be non-NULL + High: PE: Unpack colocation sets correctly + High: Tools: crm_mon - Prevent use-of-NULL for orphaned resources + Medium: ais: Add support for a synchronous call to retrieve the nodes nodeid + Medium: ais: Allow transient clients to receive membership updates + Medium: ais: Avoid double-free in error path + Medium: ais: Include in the mebership nodes for which we have not determined their hostname + Medium: ais: Spawn the PE from the ais plugin instead of the crmd + Medium: cib: By default, new configurations use the latest schema + Medium: cib: Clean up the CIB if it was already disconnected + Medium: cib: Only incriment num_updates if something actually changed + Medium: cib: Prevent use-after-free in client after abnormal termination of the CIB + Medium: Core: Fix memory leak in xpath searches + Medium: Core: Get more details regarding parser errors + Medium: Core: Repair expand_plus_plus - do not call char2score on unexpanded values + Medium: Core: Switch to the libxml2 parser - its significantly faster + Medium: Core: Use a libxml2 library function for xml -> text conversion + Medium: crmd: Asynchronous failure actions have no parameters + Medium: crmd: Avoid calling glib functions with NULL + Medium: crmd: Do not allow an election to promote a node from S_STARTING + Medium: crmd: Do not vote if we have not completed the local startup + Medium: crmd: Fix te_update_diff() now that get_object_root() functions differently + Medium: crmd: Fix the lrmd xpath expressions to not contain quotes + Medium: crmd: If we get a join offer during an election, better restart the election + Medium: crmd: No further processing is needed when using the LRMs API call for failing resources + Medium: crmd: Only update have-quorum if the value changed + Medium: crmd: Repair the input validation logic in do_te_invoke + Medium: cts: CIBs can no longer contain comments + Medium: cts: Enable a bunch of tests that were incorrectly disabled + Medium: cts: The libxml2 parser wont allow v1 resources to use integers as parameter names + Medium: Do not use the cluster UID and GID directly. Look them up based on the configured value of HA_CCMUSER + Medium: Fix compilation when heartbeat is not supported + Medium: PE: Allow groups to be involved in optional ordering constraints + Medium: PE: Allow sets of operations to be reused by multiple resources + Medium: PE: Bug LF:1941 - Mark extra clone instances as orphans and do not show inactive ones + Medium: PE: Determin the correct migration-threshold during resource expansion + Medium: PE: Implement no-quorum-policy=suicide (FATE #303619) + Medium: pengine: Clean up resources after stopping old copies of the PE + Medium: pengine: Teach the PE how to stop old copies of itself + Medium: Tools: Backport hb_report updates + Medium: Tools: cib_shadow - On create, spawn a new shell with CIB_shadow and PS1 set accordingly + Medium: Tools: Rename cib_shadow to crm_shadow * Fri Jul 18 2008 Andrew Beekhof - 0.7.0-19 - Update source tarball to revision: 007c3a1c50f5 (unstable) tip - Statistics: Changesets: 108 Diff: 216 files changed, 4632 insertions(+), 4173 deletions(-) - Changes added since unstable-0.7 + High: admin: Fix use-after-free in crm_mon + High: ais: Change the tag for the ais plugin to "pacemaker" (used in openais.conf) + High: ais: Log terminated processes as an error + High: cib: Performance - Reorganize things to avoid calculating the XML diff twice + High: PE: Bug LF:1941 - Handle failed clone instance probes when clone-max < #nodes + High: PE: Fix memory leak in action2xml + High: PE: Make OCF_ERR_ARGS a node-level error rather than a cluster-level one + High: PE: Properly handle clones that are not installed on all nodes + Medium: admin: cibadmin - Show any validation errors if the upgrade failed + Medium: admin: cib_shadow - Implement --locate to display the underlying filename + Medium: admin: cib_shadow - Implement a --diff option + Medium: admin: cib_shadow - Implement a --switch option + Medium: admin: crm_resource - create more compact constraints that do not use lifetime (which is deprecated) + Medium: ais: Approximate born_on for OpenAIS based clusters + Medium: cib: Remove do_id_check, it is a poor substitute for ID validation by a schema + Medium: cib: Skip construction of pre-notify messages if no-one wants one + Medium: Core: Attempt to streamline some key functions to increase performance + Medium: Core: Clean up XML parser after validation + Medium: crmd: Detect and optimize the CRMs behavior when processing diffs of an LRM refresh + Medium: Fix memory leaks when resetting the name of an XML object + Medium: PE: Prefer the current location if it is one of a group of nodes with the same (highest) score * Wed Jun 25 2008 Andrew Beekhof - 0.7.0-1 - Update source tarball to revision: bde0c7db74fb tip - Statistics: Changesets: 439 Diff: 676 files changed, 41310 insertions(+), 52071 deletions(-) - Changes added since stable-0.6 + High: A new tool for setting up and invoking CTS + High: Admin: All tools now use --node (-N) for specifying node unames + High: Admin: All tools now use --xml-file (-x) and --xml-text (-X) for specifying where to find XML blobs + High: cib: Cleanup the API - remove redundant input fields + High: cib: Implement CIB_shadow - a facility for making and testing changes before uploading them to the cluster + High: cib: Make registering per-op callbacks an API call and renamed (for clarity) the API call for requesting notifications + High: Core: Add a facility for automatically upgrading old configurations + High: Core: Adopt libxml2 as the XML processing library - all external clients need to be recompiled + High: Core: Allow sending TLS messages larger than the MTU + High: Core: Fix parsing of time-only ISO dates + High: Core: Smarter handling of XML values containing quotes + High: Core: XML memory corruption - catch, and handle, cases where we are overwriting an attribute value with itself + High: Core: The xml ID type does not allow UUIDs that start with a number + High: Core: Implement XPath based versions of query/delete/replace/modify + High: Core: Remove some HA2.0.(3,4) compatability code + High: crmd: Overhaul the detection of nodes that are starting vs. failed + High: PE: Bug LF:1459 - Allow failures to expire + High: PE: Have the PE do non-persistent configuration upgrades before performing calculations + High: PE: Replace failure-stickiness with a simple 'migration-threshold' + High: TE: Simplify the design by folding the tengine process into the crmd + Medium: Admin: Bug LF:1438 - Allow the list of all/active resource operations to be queried by crm_resource + Medium: Admin: Bug LF:1708 - crm_resource should print a warning if an attribute is already set as a meta attribute + Medium: Admin: Bug LF:1883 - crm_mon should display fail-count and operation history + Medium: Admin: Bug LF:1883 - crm_mon should display operation timing data + Medium: Admin: Bug N:371785 - crm_resource -C does not also clean up fail-count attributes + Medium: Admin: crm_mon - include timing data for failed actions + Medium: ais: Read options from the environment since objdb is not completely usable yet + Medium: cib: Add sections for op_defaults and rsc_defaults + Medium: cib: Better matching notification callbacks (for detecting duplicates and removal) + Medium: cib: Bug LF:1348 - Allow rules and attribute sets to be referenced for use in other objects + Medium: cib: BUG LF:1918 - By default, all cib calls now timeout after 30s + Medium: cib: Detect updates that decrease the version tuple + Medium: cib: Implement a client-side operation timeout - Requires LHA update + Medium: cib: Implement callbacks and async notifications for remote connections + Medium: cib: Make cib->cmds->update() an alias for modify at the API level (also implemented in cibadmin) + Medium: cib: Mark the CIB as disconnected if the IPC connection is terminated + Medium: cib: New call option 'cib_can_create' which can be passed to modify actions - allows the object to be created if it does not exist yet + Medium: cib: Reimplement get|set|delete attributes using XPath + Medium: cib: Remove some useless parts of the API + Medium: cib: Remove the 'attributes' scaffolding from the new format + Medium: cib: Implement the ability for clients to connect to remote servers + Medium: Core: Add support for validating xml against RelaxNG schemas + Medium: Core: Allow more than one item to be modified/deleted in XPath based operations + Medium: Core: Fix the sort_pairs function for creating sorted xml objects + Medium: Core: iso8601 - Implement subtract_duration and fix subtract_time + Medium: Core: Reduce the amount of xml copying occuring + Medium: Core: Support value='value+=N' XML updates (in addtion to value='value++') + Medium: crmd: Add support for lrm_ops->fail_rsc if its available + Medium: crmd: HB - watch link status for node leaving events + Medium: crmd: Bug LF:1924 - Improved handling of lrmd disconnects and shutdowns + Medium: crmd: Do not wait for actions with a start_delay over 5 minutes. Confirm them immediately + Medium: PE: Bug LF:1328 - Do not fencing nodes in clusters without managed resources + Medium: PE: Bug LF:1461 - Give transient node attributes (in ) preference over persistent ones (in ) + Medium: PE: Bug LF:1884, Bug LF:1885 - Implement N:M ordering and colocation constraints + Medium: PE: Bug LF:1886 - Create a resource and operation 'defaults' config section + Medium: PE: Bug LF:1892 - Allow recurring actions to be triggered at known times + Medium: PE: Bug LF:1926 - Probes should complete before stop actions are invoked + Medium: PE: Fix the standby when its set as a transient attribute + Medium: PE: Implement a global 'stop-all-resources' option + Medium: PE: Implement cibpipe, a tool for performing/simulating config changes "offline" + Medium: PE: We do not allow colocation with specific clone instances + Medium: Tools: pingd - Implement a stack-independant version of pingd + Medium: xml: Ship an xslt for upgrading from 0.6 to 0.7 * Thu Jun 19 2008 Andrew Beekhof - 0.6.5-1 - Update source tarball to revision: b9fe723d1ac5 tip - Statistics: Changesets: 48 Diff: 37 files changed, 1204 insertions(+), 234 deletions(-) - Changes since Pacemaker-0.6.4 + High: Admin: Repair the ability to delete failcounts + High: ais: Audit IPC handling between the AIS plugin and CRM processes + High: ais: Have the plugin create needed /var/lib directories + High: ais: Make sure the sync and async connections are assigned correctly (not swapped) + High: cib: Correctly detect configuration changes - num_updates does not count + High: PE: Apply stickiness values to the whole group, not the individual resources + High: PE: Bug N:385265 - Ensure groups are migrated instead of remaining partially active on the current node + High: PE: Bug N:396293 - Enforce manditory group restarts due to ordering constraints + High: PE: Correctly recover master instances found active on more than one node + High: PE: Fix memory leaks reported by Valgrind + Medium: Admin: crm_mon - Misc improvements from Satomi Taniguchi + Medium: Bug LF:1900 - Resource stickiness should not allow placement in asynchronous clusters + Medium: crmd: Ensure joins are completed promptly when a node taking part dies + Medium: PE: Avoid clone instance shuffling in more cases + Medium: PE: Bug LF:1906 - Remove an optimization in native_merge_weights() causing group scores to behave eratically + Medium: PE: Make use of target_rc data to correctly process resource operations + Medium: PE: Prevent a possible use of NULL in sort_clone_instance() + Medium: TE: Include target rc in the transition key - used to correctly determin operation failure * Thu May 22 2008 Andrew Beekhof - 0.6.4-1 - Update source tarball to revision: 226d8e356924 tip - Statistics: Changesets: 55 Diff: 199 files changed, 7103 insertions(+), 12378 deletions(-) - Changes since Pacemaker-0.6.3 + High: crmd: Bug LF:1881 LF:1882 - Overhaul the logic for operation cancelation and deletion + High: crmd: Bug LF:1894 - Make sure cancelled recurring operations are cleaned out from the CIB + High: PE: Bug N:387749 - Colocation with clones causes unnecessary clone instance shuffling + High: PE: Ensure 'master' monitor actions are cancelled _before_ we demote the resource + High: PE: Fix assert failure leading to core dump - make sure variable is properly initialized + High: PE: Make sure 'slave' monitoring happens after the resource has been demoted + High: PE: Prevent failure stickiness underflows (where too many failures become a _positive_ preference) + Medium: Admin: crm_mon - Only complain if the output file could not be opened + Medium: Common: filter_action_parameters - enable legacy handling only for older versions + Medium: PE: Bug N:385265 - The failure stickiness of group children is ignored until it reaches -INFINITY + Medium: PE: Implement master and clone colocation by exlcuding nodes rather than setting ones score to INFINITY (similar to cs: 756afc42dc51) + Medium: TE: Bug LF:1875 - Correctly find actions to cancel when their node leaves the cluster * Wed Apr 23 2008 Andrew Beekhof - 0.6.3-1 - Update source tarball to revision: fd8904c9bc67 tip - Statistics: Changesets: 117 Diff: 354 files changed, 19094 insertions(+), 11338 deletions(-) - Changes since Pacemaker-0.6.2 + High: Admin: Bug LF:1848 - crm_resource - Pass set name and id to delete_resource_attr() in the correct order + High: Build: SNMP has been moved to the management/pygui project + High: crmd: Bug LF1837 - Unmanaged resources prevent crmd from shutting down + High: crmd: Prevent use-after-free in lrm interface code (Patch based on work by Keisuke MORI) + High: PE: Allow the cluster to make progress by not retrying failed demote actions + High: PE: Anti-colocation with slave should not prevent master colocation + High: PE: Bug LF 1768 - Wait more often for STONITH ops to complete before starting resources + High: PE: Bug LF1836 - Allow is-managed-default=false to be overridden by individual resources + High: PE: Bug LF185 - Prevent pointless master/slave instance shuffling by ignoring the master-pref of stopped instances + High: PE: Bug N-191176 - Implement interleaved ordering for clone-to-clone scenarios + High: PE: Bug N-347004 - Ensure clone notifications are always sent when an instance is stopped/started + High: PE: Bug N-347004 - Include notification ordering is correct for interleaved clones + High: PE: Bug PM-11 - Directly link probe_complete to starting clone instances + High: PE: Bug PM1 - Fix setting failcounts when applied to complex resources + High: PE: Bug PM12, LF1648 - Extensive revision of group ordering + High: PE: Bug PM7 - Ensure masters are always demoted before they are stopped + High: PE: Create probes after allocation to allow smarter handling of anonymous clones + High: PE: Do not prioritize clone instances that must be moved + High: PE: Fix error in previous commit that allowed more than the required number of masters to be promoted + High: PE: Group start ordering fixes + High: PE: Implement promote/demote ordering for cloned groups + High: TE: Repair failcount updates + High: TE: Use the correct offset when updating failcount + Medium: Admin: Add a summary output that can be easily parsed by CTS for audit purposes + Medium: Build: Make configure fail if bz2 or libxml2 are not present + Medium: Build: Re-instate a better default for LCRSODIR + Medium: CIB: Bug LF-1861 - Filter irrelvant error status from synchronous CIB clients + Medium: Core: Bug 1849 - Invalid conversion of ordinal leap year to gregorian date + Medium: Core: Drop compataibility code for 2.0.4 and 2.0.5 clusters + Medium: crmd: Bug LF-1860 - Automatically cancel recurring ops before demote and promote operations (not only stops) + Medium: crmd: Save the current CIB contents if we detect the PE crashed + Medium: PE: Bug LF:1866 - Fix version check when applying compatability handling for failed start operations + Medium: PE: Bug LF:1866 - Restore the ability to have start failures not be fatal + Medium: PE: Bug PM1 - Failcount applies to all instances of non-unique clone + Medium: PE: Correctly set the state of partially active master/slave groups + Medium: PE: Do not claim to be stopping an already stopped orphan + Medium: PE: Ensure implies_left ordering constraints are always effective + Medium: PE: Indicate each resources 'promotion' score + Medium: PE: Prevent a possible use-of-NULL + Medium: PE: Reprocess the current action if it changed (so that any prior dependancies are updated) + Medium: TE: Bug LF-1859 - Wait for fail-count updates to complete before terminating the transition + Medium: TE: Bug LF:1859 - Do not abort graphs due to our own failcount updates + Medium: TE: Bug LF:1859 - Prevent the TE from interupting itself * Thu Feb 14 2008 Andrew Beekhof - 0.6.2-1 - Update source tarball to revision: 28b1a8c1868b tip - Statistics: Changesets: 11 Diff: 7 files changed, 58 insertions(+), 18 deletions(-) - Changes since Pacemaker-0.6.1 + haresources2cib.py: set default-action-timeout to the default (20s) + haresources2cib.py: update ra parameters lists + Medium: SNMP: Allow the snmp subagent to be built (patch from MATSUDA, Daiki) + Medium: Tools: Make sure the autoconf variables in haresources2cib are expanded * Tue Feb 12 2008 Andrew Beekhof - 0.6.1-1 - Update source tarball to revision: e7152d1be933 tip - Statistics: Changesets: 25 Diff: 37 files changed, 1323 insertions(+), 227 deletions(-) - Changes since Pacemaker-0.6.0 + High: CIB: Ensure changes to top-level attributes (like admin_epoch) cause a disk write + High: CIB: Ensure the archived file hits the disk before returning + High: CIB: Repair the ability to do 'atomic incriment' updates (value="value++") + High: crmd: Bug #7 - Connecting to the crmd immediately after startup causes use-of-NULL + Medium: CIB: Mask cib_diff_resync results from the caller - they do not need to know + Medium: crmd: Delay starting the IPC server until we are fully functional + Medium: CTS: Fix the startup patterns + Medium: PE: Bug 1820 - Allow the first resource in a group to be migrated + Medium: PE: Bug 1820 - Check the colocation dependancies of resources to be migrated * Mon Jan 14 2008 Andrew Beekhof - 0.6.0-2 - This is the first release of the Pacemaker Cluster Resource Manager formerly part of Heartbeat. - For those looking for the GUI, mgmtd, CIM or TSA components, they are now found in the new pacemaker-pygui project. Build dependancies prevent them from being included in Heartbeat (since the built-in CRM is no longer supported) and, being non-core components, are not included with Pacemaker. - Update source tarball to revision: c94b92d550cf - Statistics: Changesets: 347 Diff: 2272 files changed, 132508 insertions(+), 305991 deletions(-) - Test hardware: + 6-node vmware cluster (sles10-sp1/256Mb/vmware stonith) on a single host (opensuse10.3/2Gb/2.66Ghz Quad Core2) + 7-node EMC Centera cluster (sles10/512Mb/2Ghz Xeon/ssh stonith) - Notes: Heartbeat Stack + All testing was performed with STONITH enabled + The CRM was enabled using the "crm respawn" directive - Notes: OpenAIS Stack + This release contains a preview of support for the OpenAIS cluster stack + The current release of the OpenAIS project is missing two important patches that we require. OpenAIS packages containing these patches are available for most major distributions at: http://download.opensuse.org/repositories/server:/ha-clustering + The OpenAIS stack is not currently recommended for use in clusters that have shared data as STONITH support is not yet implimented + pingd is not yet available for use with the OpenAIS stack + 3 significant OpenAIS issues were found during testing of 4 and 6 node clusters. We are activly working together with the OpenAIS project to get these resolved. - Pending bugs encountered during testing: + OpenAIS #1736 - Openais membership took 20s to stabilize + Heartbeat #1750 - ipc_bufpool_update: magic number in head does not match + OpenAIS #1793 - Assertion failure in memb_state_gather_enter() + OpenAIS #1796 - Cluster message corruption - Changes since Heartbeat-2.1.2-24 + High: Add OpenAIS support + High: Admin: crm_uuid - Look in the right place for Heartbeat UUID files + High: admin: Exit and indicate a problem if the crmd exits while crmadmin is performing a query + High: cib: Fix CIB_OP_UPDATE calls that modify the whole CIB + High: cib: Fix compilation when supporting the heartbeat stack + High: cib: Fix memory leaks caused by the switch to get_message_xml() + High: cib: HA_VALGRIND_ENABLED needs to be set _and_ set to 1|yes|true + High: cib: Use get_message_xml() in preference to cl_get_struct() + High: cib: Use the return value from call to write() in cib_send_plaintext() + High: Core: ccm nodes can legitimately have a node id of 0 + High: Core: Fix peer-process tracking for the Heartbeat stack + High: Core: Heartbeat does not send status notifications for nodes that were already part of the cluster. Fake them instead + High: CRM: Add children to HA_Messages such that the field name matches F_XML_TAGNAME + High: crm: Adopt a more flexible appraoch to enabling Valgrind + High: crm: Fix compilation when bzip2 is not installed + High: CRM: Future-proof get_message_xml() + High: crmd: Filter election responses based on time not FSA state + High: crmd: Handle all possible peer states in crmd_ha_status_callback() + High: crmd: Make sure the current date/time is set - prevents use-of-NULL when evaluating rules + High: crmd: Relax an assertion regrading ccm membership instances + High: crmd: Use (node->processes&crm_proc_ais) to accurately update the CIB after replace operations + High: crmd: Heartbeat: Accurately record peer client status + High: PE: Bug 1777 - Allow colocation with a resource in the Stopped state + High: PE: Bug 1822 - Prevent use-of-NULL in PromoteRsc() + High: PE: Implement three recovery policies based on op_status and op_rc + High: PE: Parse fail-count correctly (it may be set to ININFITY) + High: PE: Prevent graph-loop when stonith agents need to be moved around before a STONITH op + High: PE: Prevent graph-loops when two operations have the same name+interval + High: te: Cancel active timers when destroying graphs + High: TE: Ensure failcount is set correctly for failed stops/starts + High: TE: Update failcount for oeprations that time out + Medium: admin: Prevent hang in crm_mon -1 when there is no cib connection - Patch from Junko IKEDA + Medium: cib: Require --force|-f when performing potentially dangerous commands with cibadmin + Medium: cib: Tweak the shutdown code + Medium: Common: Only count peer processes of active nodes + Medium: Core: Create generic cluster sign-in method + Medium: core: Fix compilation when Heartbeat support is disabled + Medium: Core: General cleanup for supporting two stacks + Medium: Core: iso6601 - Support parsing of time-only strings + Medium: core: Isolate more code that is only needed when SUPPORT_HEARTBEAT is enabled + Medium: crm: Improved logging of errors in the XML parser + Medium: crmd: Fix potential use-of-NULL in string comparison + Medium: crmd: Reimpliment syncronizing of CIB queries and updates when invoking the PE + Medium: crm_mon: Indicate when a node is both in standby mode and offline + Medium: PE: Bug 1822 - Do not try an promote groups if not all of it is active + Medium: PE: on_fail=nothing is an alias for 'ignore' not 'restart' + Medium: PE: Prevent a potential use-of-NULL in cron_range_satisfied() + snmp subagent: fix a problem on displaying an unmanaged group + snmp subagent: use the syslog setting + snmp: v2 support (thanks to Keisuke MORI) + snmp_subagent - made it not complain about some things if shutting down * Mon Dec 10 2007 Andrew Beekhof - 0.6.0-1 - Initial opensuse package check-in diff --git a/tools/shell/Makefile.am b/shell/Makefile.am similarity index 100% rename from tools/shell/Makefile.am rename to shell/Makefile.am diff --git a/tools/shell/regression/001.exp.xml b/shell/regression/001.exp.xml similarity index 100% rename from tools/shell/regression/001.exp.xml rename to shell/regression/001.exp.xml diff --git a/tools/shell/regression/001.input b/shell/regression/001.input similarity index 100% rename from tools/shell/regression/001.input rename to shell/regression/001.input diff --git a/tools/shell/regression/002.exp.xml b/shell/regression/002.exp.xml similarity index 100% rename from tools/shell/regression/002.exp.xml rename to shell/regression/002.exp.xml diff --git a/tools/shell/regression/002.input b/shell/regression/002.input similarity index 100% rename from tools/shell/regression/002.input rename to shell/regression/002.input diff --git a/tools/shell/regression/003.exp.xml b/shell/regression/003.exp.xml similarity index 100% rename from tools/shell/regression/003.exp.xml rename to shell/regression/003.exp.xml diff --git a/tools/shell/regression/003.input b/shell/regression/003.input similarity index 100% rename from tools/shell/regression/003.input rename to shell/regression/003.input diff --git a/tools/shell/regression/004.exp.xml b/shell/regression/004.exp.xml similarity index 100% rename from tools/shell/regression/004.exp.xml rename to shell/regression/004.exp.xml diff --git a/tools/shell/regression/004.input b/shell/regression/004.input similarity index 100% rename from tools/shell/regression/004.input rename to shell/regression/004.input diff --git a/tools/shell/regression/Makefile.am b/shell/regression/Makefile.am similarity index 100% rename from tools/shell/regression/Makefile.am rename to shell/regression/Makefile.am diff --git a/tools/shell/regression/README.regression b/shell/regression/README.regression similarity index 100% rename from tools/shell/regression/README.regression rename to shell/regression/README.regression diff --git a/tools/shell/regression/crm-interface b/shell/regression/crm-interface similarity index 100% rename from tools/shell/regression/crm-interface rename to shell/regression/crm-interface diff --git a/tools/shell/regression/crm_regression.sh b/shell/regression/crm_regression.sh similarity index 100% rename from tools/shell/regression/crm_regression.sh rename to shell/regression/crm_regression.sh diff --git a/tools/shell/regression/defaults b/shell/regression/defaults similarity index 100% rename from tools/shell/regression/defaults rename to shell/regression/defaults diff --git a/tools/shell/regression/descriptions b/shell/regression/descriptions similarity index 100% rename from tools/shell/regression/descriptions rename to shell/regression/descriptions diff --git a/tools/shell/regression/empty.xml b/shell/regression/empty.xml similarity index 100% rename from tools/shell/regression/empty.xml rename to shell/regression/empty.xml diff --git a/tools/shell/regression/evaltest.sh b/shell/regression/evaltest.sh similarity index 100% rename from tools/shell/regression/evaltest.sh rename to shell/regression/evaltest.sh diff --git a/tools/shell/regression/lrmregtest-lsb.in b/shell/regression/lrmregtest-lsb.in similarity index 100% rename from tools/shell/regression/lrmregtest-lsb.in rename to shell/regression/lrmregtest-lsb.in diff --git a/tools/shell/regression/regression.sh.in b/shell/regression/regression.sh.in similarity index 100% rename from tools/shell/regression/regression.sh.in rename to shell/regression/regression.sh.in diff --git a/tools/shell/regression/shadow.base b/shell/regression/shadow.base similarity index 100% rename from tools/shell/regression/shadow.base rename to shell/regression/shadow.base diff --git a/tools/shell/regression/testcases/BSC b/shell/regression/testcases/BSC similarity index 100% rename from tools/shell/regression/testcases/BSC rename to shell/regression/testcases/BSC diff --git a/tools/shell/regression/testcases/Makefile.am b/shell/regression/testcases/Makefile.am similarity index 100% rename from tools/shell/regression/testcases/Makefile.am rename to shell/regression/testcases/Makefile.am diff --git a/tools/shell/regression/testcases/basicset b/shell/regression/testcases/basicset similarity index 100% rename from tools/shell/regression/testcases/basicset rename to shell/regression/testcases/basicset diff --git a/tools/shell/regression/testcases/common.excl b/shell/regression/testcases/common.excl similarity index 100% rename from tools/shell/regression/testcases/common.excl rename to shell/regression/testcases/common.excl diff --git a/tools/shell/regression/testcases/confbasic b/shell/regression/testcases/confbasic similarity index 100% rename from tools/shell/regression/testcases/confbasic rename to shell/regression/testcases/confbasic diff --git a/tools/shell/regression/testcases/confbasic-xml b/shell/regression/testcases/confbasic-xml similarity index 100% rename from tools/shell/regression/testcases/confbasic-xml rename to shell/regression/testcases/confbasic-xml diff --git a/tools/shell/regression/testcases/confbasic-xml.exp b/shell/regression/testcases/confbasic-xml.exp similarity index 100% rename from tools/shell/regression/testcases/confbasic-xml.exp rename to shell/regression/testcases/confbasic-xml.exp diff --git a/tools/shell/regression/testcases/confbasic.exp b/shell/regression/testcases/confbasic.exp similarity index 100% rename from tools/shell/regression/testcases/confbasic.exp rename to shell/regression/testcases/confbasic.exp diff --git a/tools/shell/regression/testcases/delete b/shell/regression/testcases/delete similarity index 100% rename from tools/shell/regression/testcases/delete rename to shell/regression/testcases/delete diff --git a/tools/shell/regression/testcases/delete.exp b/shell/regression/testcases/delete.exp similarity index 100% rename from tools/shell/regression/testcases/delete.exp rename to shell/regression/testcases/delete.exp diff --git a/tools/shell/regression/testcases/file b/shell/regression/testcases/file similarity index 100% rename from tools/shell/regression/testcases/file rename to shell/regression/testcases/file diff --git a/tools/shell/regression/testcases/file.exp b/shell/regression/testcases/file.exp similarity index 100% rename from tools/shell/regression/testcases/file.exp rename to shell/regression/testcases/file.exp diff --git a/tools/shell/regression/testcases/node b/shell/regression/testcases/node similarity index 100% rename from tools/shell/regression/testcases/node rename to shell/regression/testcases/node diff --git a/tools/shell/regression/testcases/node.exp b/shell/regression/testcases/node.exp similarity index 100% rename from tools/shell/regression/testcases/node.exp rename to shell/regression/testcases/node.exp diff --git a/tools/shell/regression/testcases/ra b/shell/regression/testcases/ra similarity index 100% rename from tools/shell/regression/testcases/ra rename to shell/regression/testcases/ra diff --git a/tools/shell/regression/testcases/ra.exp b/shell/regression/testcases/ra.exp similarity index 100% rename from tools/shell/regression/testcases/ra.exp rename to shell/regression/testcases/ra.exp diff --git a/tools/shell/regression/testcases/resource b/shell/regression/testcases/resource similarity index 100% rename from tools/shell/regression/testcases/resource rename to shell/regression/testcases/resource diff --git a/tools/shell/regression/testcases/resource.exp b/shell/regression/testcases/resource.exp similarity index 100% rename from tools/shell/regression/testcases/resource.exp rename to shell/regression/testcases/resource.exp diff --git a/tools/shell/regression/testcases/shadow b/shell/regression/testcases/shadow similarity index 100% rename from tools/shell/regression/testcases/shadow rename to shell/regression/testcases/shadow diff --git a/tools/shell/regression/testcases/shadow.exp b/shell/regression/testcases/shadow.exp similarity index 100% rename from tools/shell/regression/testcases/shadow.exp rename to shell/regression/testcases/shadow.exp diff --git a/tools/shell/regression/testcases/xmlonly.sh b/shell/regression/testcases/xmlonly.sh similarity index 100% rename from tools/shell/regression/testcases/xmlonly.sh rename to shell/regression/testcases/xmlonly.sh diff --git a/tools/shell/templates/Makefile.am b/shell/templates/Makefile.am similarity index 100% rename from tools/shell/templates/Makefile.am rename to shell/templates/Makefile.am diff --git a/tools/shell/templates/apache b/shell/templates/apache similarity index 100% rename from tools/shell/templates/apache rename to shell/templates/apache diff --git a/tools/shell/templates/clvm b/shell/templates/clvm similarity index 100% rename from tools/shell/templates/clvm rename to shell/templates/clvm diff --git a/tools/shell/templates/filesystem b/shell/templates/filesystem similarity index 100% rename from tools/shell/templates/filesystem rename to shell/templates/filesystem diff --git a/tools/shell/templates/gfs2 b/shell/templates/gfs2 similarity index 100% rename from tools/shell/templates/gfs2 rename to shell/templates/gfs2 diff --git a/tools/shell/templates/gfs2-base b/shell/templates/gfs2-base similarity index 100% rename from tools/shell/templates/gfs2-base rename to shell/templates/gfs2-base diff --git a/tools/shell/templates/ocfs2 b/shell/templates/ocfs2 similarity index 100% rename from tools/shell/templates/ocfs2 rename to shell/templates/ocfs2 diff --git a/tools/shell/templates/virtual-ip b/shell/templates/virtual-ip similarity index 100% rename from tools/shell/templates/virtual-ip rename to shell/templates/virtual-ip diff --git a/tools/Makefile.am b/tools/Makefile.am index 64f1273f21..638248377d 100644 --- a/tools/Makefile.am +++ b/tools/Makefile.am @@ -1,148 +1,146 @@ # # Copyright (C) 2004-2009 Andrew Beekhof # # This program is free software; you can redistribute it and/or # modify it under the terms of the GNU General Public License # as published by the Free Software Foundation; either version 2 # of the License, or (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program; if not, write to the Free Software # Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. # MAINTAINERCLEANFILES = Makefile.in -SUBDIRS = shell - INCLUDES = -I$(top_builddir)/include -I$(top_srcdir)/include \ -I$(top_builddir)/libltdl -I$(top_srcdir)/libltdl COMMONLIBS = \ $(top_builddir)/lib/common/libcrmcommon.la \ $(top_builddir)/lib/cib/libcib.la \ $(CURSESLIBS) $(CLUSTERLIBS) headerdir = $(pkgincludedir)/crm header_HEADERS = attrd.h EXTRA_DIST = $(sbin_SCRIPTS) halibdir = $(CRM_DAEMON_DIR) halib_SCRIPTS = haresources2cib.py hb2openais.sh halib_PROGRAMS = attrd pingd halib_PYTHON = crm_primitive.py hb2openais-helper.py sbin_PROGRAMS = crm_simulate crmadmin cibadmin crm_node crm_attribute crm_resource crm_verify \ crm_uuid crm_shadow attrd_updater crm_diff crm_mon iso8601 testdir = $(datadir)/$(PACKAGE)/tests/cli test_SCRIPTS = regression.sh test_DATA = regression.exp if BUILD_SERVICELOG sbin_PROGRAMS += notifyServicelogEvent endif if BUILD_OPENIPMI_SERICELOG sbin_PROGRAMS += ipmiservicelogd endif if BUILD_HELP man8_MANS = $(sbin_PROGRAMS:%=%.8) endif sbin_SCRIPTS = crm crm_standby crm_master crm_failcount ## SOURCES #noinst_HEADERS = config.h control.h crmd.h noinst_HEADERS = crmadmin_SOURCES = crmadmin.c crmadmin_LDADD = $(COMMONLIBS) $(CLUSTERLIBS) \ $(top_builddir)/lib/pengine/libpe_status.la crm_uuid_SOURCES = crm_uuid.c crm_uuid_LDADD = $(top_builddir)/lib/common/libcrmcluster.la cibadmin_SOURCES = cibadmin.c cibadmin_LDADD = $(COMMONLIBS) crm_shadow_SOURCES = cib_shadow.c crm_shadow_LDADD = $(COMMONLIBS) crm_node_SOURCES = ccm_epoche.c crm_node_LDADD = $(COMMONLIBS) $(CLUSTERLIBS) \ $(top_builddir)/lib/common/libcrmcluster.la crm_simulate_SOURCES = crm_inject.c crm_simulate_CFLAGS = -I$(top_srcdir)/pengine crm_simulate_LDADD = $(COMMONLIBS) \ $(top_builddir)/lib/pengine/libpe_status.la \ $(top_builddir)/pengine/libpengine.la \ $(top_builddir)/lib/cib/libcib.la \ $(top_builddir)/lib/transition/libtransitioner.la crm_diff_SOURCES = xml_diff.c crm_diff_LDADD = $(COMMONLIBS) crm_mon_SOURCES = crm_mon.c crm_mon_LDADD = $(COMMONLIBS) $(SNMPLIBS) $(ESMTPLIBS) -llrm \ $(top_builddir)/lib/pengine/libpe_status.la # Arguments could be made that this should live in crm/pengine crm_verify_SOURCES = crm_verify.c crm_verify_LDADD = $(COMMONLIBS) \ $(top_builddir)/lib/pengine/libpe_status.la \ $(top_builddir)/pengine/libpengine.la crm_attribute_SOURCES = crm_attribute.c crm_attribute_LDADD = $(COMMONLIBS) crm_resource_SOURCES = crm_resource.c crm_resource_LDADD = $(COMMONLIBS) \ $(top_builddir)/lib/pengine/libpe_rules.la \ $(top_builddir)/lib/pengine/libpe_status.la \ $(top_builddir)/pengine/libpengine.la iso8601_SOURCES = test.iso8601.c iso8601_LDADD = $(COMMONLIBS) attrd_SOURCES = attrd.c attrd_LDADD = $(COMMONLIBS) $(top_builddir)/lib/common/libcrmcluster.la pingd_SOURCES = pingd.c pingd_LDADD = $(COMMONLIBS) attrd_updater_SOURCES = attrd_updater.c attrd_updater_LDADD = $(COMMONLIBS) if BUILD_SERVICELOG notifyServicelogEvent_SOURCES = notifyServicelogEvent.c notifyServicelogEvent_CFLAGS = `pkg-config --cflags servicelog-1` notifyServicelogEvent_LDFLAGS = `pkg-config --libs servicelog-1` $(top_builddir)/lib/common/libcrmcommon.la endif if BUILD_OPENIPMI_SERICELOG ipmiservicelogd_SOURCES = ipmiservicelogd.c ipmiservicelogd_CFLAGS = `pkg-config --cflags OpenIPMI OpenIPMIposix servicelog-1` ipmiservicelogd_LDFLAGS = `pkg-config --libs OpenIPMI OpenIPMIposix servicelog-1` $(top_builddir)/lib/common/libcrmcommon.la endif %.8: % echo Creating $@ help2man --output $@ --no-info --section 8 --name "Part of the Pacemaker cluster resource manager" $(top_builddir)/tools/$< clean-generic: rm -f *.log *.debug *.xml *~ install-exec-local: uninstall-local: .PHONY: install-exec-hook diff --git a/tools/ccm_epoche.c b/tools/ccm_epoche.c index 827bbb5d18..1c604e5ea8 100644 --- a/tools/ccm_epoche.c +++ b/tools/ccm_epoche.c @@ -1,446 +1,446 @@ /* * Copyright (C) 2004 Andrew Beekhof * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public * License as published by the Free Software Foundation; either * version 2.1 of the License, or (at your option) any later version. * * This software is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * General Public License for more details. * * You should have received a copy of the GNU General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ #include #include #include #include #include #include #include #include #include /* for basename() */ #include #include #include #include int command = 0; int ccm_fd = 0; int try_hb = 1; int try_ais = 1; gboolean do_quiet = FALSE; char *target_uuid = NULL; char *target_uname = NULL; const char *standby_value = NULL; const char *standby_scope = NULL; void ais_membership_destroy(gpointer user_data); gboolean ais_membership_dispatch(AIS_Message *wrapper, char *data, int sender); #include <../lib/common/stack.h> #if SUPPORT_HEARTBEAT # include # include # include # define UUID_LEN 16 oc_ev_t *ccm_token = NULL; void oc_ev_special(const oc_ev_t *, oc_ev_class_t , int ); void ccm_age_callback( oc_ed_t event, void *cookie, size_t size, const void *data); gboolean ccm_age_connect(int *ccm_fd); static int read_local_hb_uuid(void) { int rc = 0; cl_uuid_t uuid; char *buffer = NULL; long start = 0, read_len = 0; FILE *input = fopen(UUID_FILE, "r"); if(input == NULL) { cl_perror("Could not open UUID file %s\n", UUID_FILE); return 1; } /* see how big the file is */ start = ftell(input); fseek(input, 0L, SEEK_END); if(UUID_LEN != ftell(input)) { fprintf(stderr, "%s must contain exactly %d bytes\n", UUID_FILE, UUID_LEN); abort(); } fseek(input, 0L, start); if(start != ftell(input)) { fprintf(stderr, "fseek not behaving: %ld vs. %ld\n", start, ftell(input)); rc = 2; goto bail; } buffer = malloc(50); read_len = fread(uuid.uuid, 1, UUID_LEN, input); if(read_len != UUID_LEN) { fprintf(stderr, "Expected and read bytes differ: %d vs. %ld\n", UUID_LEN, read_len); rc = 3; goto bail; } else if(buffer != NULL) { cl_uuid_unparse(&uuid, buffer); fprintf(stdout, "%s\n", buffer); } else { fprintf(stderr, "No buffer to unparse\n"); rc = 4; } bail: free(buffer); fclose(input); return rc; } #endif static struct crm_option long_options[] = { /* Top-level Options */ {"help", 0, 0, '?', "\tThis text"}, {"version", 0, 0, '$', "\tVersion information" }, {"verbose", 0, 0, 'V', "\tIncrease debug output"}, {"quiet", 0, 0, 'Q', "\tEssential output only"}, {"-spacer-", 1, 0, '-', "\nStack:", SUPPORT_HEARTBEAT}, {"openais", 0, 0, 'A', "\tOnly try connecting to an OpenAIS-based cluster", SUPPORT_HEARTBEAT}, {"heartbeat", 0, 0, 'H', "Only try connecting to a Heartbeat-based cluster", SUPPORT_HEARTBEAT}, {"-spacer-", 1, 0, '-', "\nCommands:"}, {"epoch", 0, 0, 'e', "\tDisplay the epoch during which this node joined the cluster"}, {"quorum", 0, 0, 'q', "\tDisplay a 1 if our partition has quorum, 0 if not"}, {"list", 0, 0, 'l', "(AIS-Only) Display all known members (past and present) of this cluster"}, {"partition", 0, 0, 'p', "Display the members of this partition"}, {"cluster-id", 0, 0, 'i', "Display this node's cluster id"}, {"remove", 1, 0, 'R', "(Advanced, AIS-Only) Remove the (stopped) node with the specified nodeid from the cluster"}, {"-spacer-", 1, 0, '-', "\nAdditional Options:"}, {"force", 0, 0, 'f'}, {0, 0, 0, 0} }; int local_id = 0; int main(int argc, char ** argv) { int flag = 0; int argerr = 0; gboolean force_flag = FALSE; gboolean dangerous_cmd = FALSE; int option_index = 0; crm_peer_init(); - crm_log_init(basename(argv[0]), LOG_WARNING, FALSE, FALSE, 0, NULL); + crm_log_init(basename(argv[0]), LOG_WARNING, FALSE, FALSE, argc, argv); crm_set_options("?V$qepHR:ifl", "command [options]", long_options, "Tool for displaying low-level node information"); while (flag >= 0) { flag = crm_get_option(argc, argv, &option_index); switch(flag) { case -1: break; case 'V': cl_log_enable_stderr(TRUE); alter_debug(DEBUG_INC); break; case '$': case '?': crm_help(flag, LSB_EXIT_OK); break; case 'Q': do_quiet = TRUE; break; case 'H': try_ais = 0; break; case 'A': try_hb = 0; break; case 'f': force_flag = TRUE; break; case 'R': dangerous_cmd = TRUE; command = flag; target_uname = optarg; break; case 'p': case 'e': case 'q': case 'i': case 'l': command = flag; break; default: ++argerr; break; } } if (optind > argc) { ++argerr; } if (argerr) { crm_help('?', LSB_EXIT_GENERIC); } if(dangerous_cmd && force_flag == FALSE) { fprintf(stderr, "The supplied command is considered dangerous." " To prevent accidental destruction of the cluster," " the --force flag is required in order to proceed.\n"); fflush(stderr); exit(LSB_EXIT_GENERIC); } #if SUPPORT_AIS if(try_ais && init_ais_connection( ais_membership_dispatch, ais_membership_destroy, NULL, NULL, &local_id)) { GMainLoop* amainloop = NULL; switch(command) { case 'R': send_ais_text(crm_class_rmpeer, target_uname, TRUE, NULL, crm_msg_ais); return 0; case 'e': /* Age makes no sense (yet) in an AIS cluster */ fprintf(stdout, "1\n"); return 0; case 'q': send_ais_text(crm_class_quorum, NULL, TRUE, NULL, crm_msg_ais); break; case 'l': case 'p': crm_info("Requesting the list of configured nodes"); send_ais_text(crm_class_members, __FUNCTION__, TRUE, NULL, crm_msg_ais); break; case 'i': printf("%d\n", local_id); default: fprintf(stderr, "Unknown option '%c'\n", command); crm_help('?', LSB_EXIT_GENERIC); } amainloop = g_main_new(FALSE); g_main_run(amainloop); } #endif #if SUPPORT_HEARTBEAT if(try_hb && command == 'i') { return read_local_hb_uuid(); } else if(try_hb && ccm_age_connect(&ccm_fd)) { int rc = 0; fd_set rset; oc_ev_t *ccm_token = NULL; while (1) { sleep(1); FD_ZERO(&rset); FD_SET(ccm_fd, &rset); errno = 0; rc = select(ccm_fd + 1, &rset, NULL,NULL,NULL); if(rc > 0 && oc_ev_handle_event(ccm_token) != 0) { crm_err("oc_ev_handle_event failed"); return 1; } else if(rc < 0 && errno != EINTR) { crm_perror(LOG_ERR, "select failed"); return 1; } } } #endif return(1); } #if SUPPORT_HEARTBEAT gboolean ccm_age_connect(int *ccm_fd) { gboolean did_fail = FALSE; int ret = 0; crm_debug("Registering with CCM"); ret = oc_ev_register(&ccm_token); if (ret != 0) { crm_warn("CCM registration failed"); did_fail = TRUE; } if(did_fail == FALSE) { crm_debug("Setting up CCM callbacks"); ret = oc_ev_set_callback(ccm_token, OC_EV_MEMB_CLASS, ccm_age_callback, NULL); if (ret != 0) { crm_warn("CCM callback not set"); did_fail = TRUE; } } if(did_fail == FALSE) { oc_ev_special(ccm_token, OC_EV_MEMB_CLASS, 0/*don't care*/); crm_debug("Activating CCM token"); ret = oc_ev_activate(ccm_token, ccm_fd); if (ret != 0){ crm_warn("CCM Activation failed"); did_fail = TRUE; } } return !did_fail; } void ccm_age_callback(oc_ed_t event, void *cookie, size_t size, const void *data) { int lpc; int node_list_size; const oc_ev_membership_t *oc = (const oc_ev_membership_t *)data; node_list_size = oc->m_n_member; if(command == 'q') { crm_debug("Processing \"%s\" event.", event==OC_EV_MS_NEW_MEMBERSHIP?"NEW MEMBERSHIP": event==OC_EV_MS_NOT_PRIMARY?"NOT PRIMARY": event==OC_EV_MS_PRIMARY_RESTORED?"PRIMARY RESTORED": event==OC_EV_MS_EVICTED?"EVICTED": "NO QUORUM MEMBERSHIP"); if(ccm_have_quorum(event)) { fprintf(stdout, "1\n"); } else { fprintf(stdout, "0\n"); } } else if(command == 'e') { crm_debug("Searching %d members for our birth", oc->m_n_member); } for(lpc=0; lpcm_array[oc->m_memb_idx+lpc].node_uname); } else if(command == 'e') { if(oc_ev_is_my_nodeid(ccm_token, &(oc->m_array[lpc]))){ crm_debug("MATCH: nodeid=%d, uname=%s, born=%d", oc->m_array[oc->m_memb_idx+lpc].node_id, oc->m_array[oc->m_memb_idx+lpc].node_uname, oc->m_array[oc->m_memb_idx+lpc].node_born_on); fprintf(stdout, "%d\n", oc->m_array[oc->m_memb_idx+lpc].node_born_on); } } } oc_ev_callback_done(cookie); if(command == 'p') { fprintf(stdout, "\n"); } fflush(stdout); exit(0); } #endif #if SUPPORT_AIS void ais_membership_destroy(gpointer user_data) { crm_err("AIS connection terminated"); ais_fd_sync = -1; exit(1); } #endif static gint member_sort(gconstpointer a, gconstpointer b) { const crm_node_t *node_a = a; const crm_node_t *node_b = b; return strcmp(node_a->uname, node_b->uname); } static void crm_add_member( gpointer key, gpointer value, gpointer user_data) { GList **list = user_data; crm_node_t *node = value; if(node->uname != NULL) { *list = g_list_insert_sorted(*list, node, member_sort); } } gboolean ais_membership_dispatch(AIS_Message *wrapper, char *data, int sender) { switch(wrapper->header.id) { case crm_class_members: case crm_class_notify: case crm_class_quorum: break; default: return TRUE; break; } if(command == 'q') { if(crm_have_quorum) { fprintf(stdout, "1\n"); } else { fprintf(stdout, "0\n"); } } else if(command == 'l') { GList *nodes = NULL; g_hash_table_foreach(crm_peer_cache, crm_add_member, &nodes); slist_iter(node, crm_node_t, nodes, lpc, fprintf(stdout, "%u %s %s\n", node->id, node->uname, node->state); ); fprintf(stdout, "\n"); } else if(command == 'p') { GList *nodes = NULL; g_hash_table_foreach(crm_peer_cache, crm_add_member, &nodes); slist_iter(node, crm_node_t, nodes, lpc, if(node->uname && crm_is_member_active(node)) { fprintf(stdout, "%s ", node->uname); } ); fprintf(stdout, "\n"); } exit(0); return TRUE; } diff --git a/tools/crm.in b/tools/crm.in index 4f937788c1..6b2f77cf34 100644 --- a/tools/crm.in +++ b/tools/crm.in @@ -1,7618 +1,7629 @@ #!/usr/bin/python # # Copyright (C) 2008 Dejan Muhamedagic # # This program is free software; you can redistribute it and/or # modify it under the terms of the GNU General Public # License as published by the Free Software Foundation; either # version 2.1 of the License, or (at your option) any later version. # # This software is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU # General Public License for more details. # # You should have received a copy of the GNU General Public # License along with this library; if not, write to the Free Software # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA # import shlex import os from tempfile import mkstemp import subprocess import sys import time import readline import copy import xml.dom.minidom import signal import re import glob def is_program(prog): return subprocess.call("which %s >/dev/null 2>&1"%prog, shell=True) == 0 def prereqs(): proglist = "which cibadmin crm_resource crm_attribute crm_mon crm_standby crm_failcount" for prog in proglist.split(): if not is_program(prog): print >> sys.stderr, "%s not available, check your installation"%prog sys.exit(1) prereqs() lineno = -1 regression_tests = False class ErrorBuffer(object): ''' Show error messages either immediately or buffered. ''' def __init__(self): self.msg_list = [] self.mode = "immediate" def buffer(self): self.mode = "keep" def release(self): if self.msg_list: print >> sys.stderr, '\n'.join(self.msg_list) if not batch: try: raw_input("Press enter to continue... ") except EOFError: pass self.msg_list = [] self.mode = "immediate" def writemsg(self,msg): if self.mode == "immediate": if regression_tests: print msg else: print >> sys.stderr, msg else: self.msg_list.append(msg) def error(self,s): self.writemsg("ERROR: %s" % add_lineno(s)) def warning(self,s): self.writemsg("WARNING: %s" % add_lineno(s)) def info(self,s): self.writemsg("INFO: %s" % add_lineno(s)) def debug(self,s): if user_prefs.get_debug(): self.writemsg("DEBUG: %s" % add_lineno(s)) err_buf = ErrorBuffer() def add_lineno(s): if lineno > 0: return "%d: %s" % (lineno,s) else: return s def common_err(s): err_buf.error(s) def common_warn(s): err_buf.warning(s) def common_info(s): err_buf.info(s) def common_debug(s): err_buf.debug(s) def no_prog_err(name): err_buf.error("%s not available, check your installation"%name) def missing_prog_warn(name): err_buf.warning("could not find any %s on the system"%name) def no_attribute_err(attr,obj_type): err_buf.error("required attribute %s not found in %s"%(attr,obj_type)) def bad_def_err(what,msg): err_buf.error("bad %s definition: %s"%(what,msg)) def unsupported_err(name): err_buf.error("%s is not supported"%name) def no_such_obj_err(name): err_buf.error("%s object is not supported"%name) def obj_cli_err(name): err_buf.error("object %s cannot be represented in the CLI notation"%name) def missing_obj_err(node): err_buf.error("object %s:%s missing (shouldn't have happened)"% \ (node.tagName,node.getAttribute("id"))) def constraint_norefobj_err(constraint_id,obj_id): err_buf.error("constraint %s references a resource %s which doesn't exist"% \ (constraint_id,obj_id)) def obj_exists_err(name): err_buf.error("object %s already exists"%name) def no_object_err(name): err_buf.error("object %s does not exist"%name) def invalid_id_err(obj_id): err_buf.error("%s: invalid object id"%obj_id) def id_used_err(node_id): err_buf.error("%s: id is already in use"%node_id) def skill_err(s): err_buf.error("%s: this command is not allowed at this skill level"%' '.join(s)) def syntax_err(s,token = '',context = ''): pfx = "syntax" if context: pfx = "%s in %s" %(pfx,context) if type(s) == type(''): err_buf.error("%s near <%s>"%(pfx,s)) elif token: err_buf.error("%s near <%s>: %s"%(pfx,token,' '.join(s))) else: err_buf.error("%s: %s"%(pfx,' '.join(s))) def bad_usage(cmd,args): err_buf.error("bad usage: %s %s"%(cmd,args)) def empty_cib_err(): err_buf.error("No CIB!") def cib_parse_err(msg): err_buf.error("%s"%msg) def cib_no_elem_err(el_name): err_buf.error("CIB contains no '%s' element!"%el_name) def cib_ver_unsupported_err(validator,rel): err_buf.error("CIB not supported: validator '%s', release '%s'"% (validator,rel)) err_buf.error("You may try the upgrade command") def update_err(obj_id,cibadm_opt,xml): if cibadm_opt == '-U': task = "update" elif cibadm_opt == '-D': task = "delete" else: task = "replace" err_buf.error("could not %s %s"%(task,obj_id)) err_buf.info("offending xml: %s" % xml) def not_impl_info(s): err_buf.info("%s is not implemented yet" % s) def ask(msg): print_msg = True while True: try: ans = raw_input(msg + ' ') except EOFError: ans = 'n' if not ans or ans[0].lower() not in ('n','y'): if print_msg: print "Please answer with y[es] or n[o]" print_msg = False else: return ans[0].lower() == 'y' def keyword_cmp(string1, string2): return string1.lower() == string2.lower() from UserDict import DictMixin class odict(DictMixin): def __init__(self, data=None, **kwdata): self._keys = [] self._data = {} def __setitem__(self, key, value): if key not in self._data: self._keys.append(key) self._data[key] = value def __getitem__(self, key): if key not in self._data: return self._data[key.lower()] return self._data[key] def __delitem__(self, key): del self._data[key] self._keys.remove(key) def keys(self): return list(self._keys) def copy(self): copyDict = odict() copyDict._data = self._data.copy() copyDict._keys = self._keys[:] return copyDict class olist(list): def __init__(self, keys): #print "Init %s" % (repr(keys)) super(olist, self).__init__() for key in keys: self.append(key) self.append(key.upper()) def help_short(s): r = re.search("help_[^,]+,(.*)\]\]", s) return r and r.group(1) or '' class HelpSystem(object): ''' The help system. All help is in the following form in the manual: [[cmdhelp__,]] === ... Long help text. ... [[cmdhelp__,]] Help for the level itself is like this: [[cmdhelp_,]] ''' - help_text_file = "@docdir@/crm_cli.txt" + help_text_file = "@datadir@/@PACKAGE@/crm_cli.txt" index_file = "%s/%s" % (os.getenv("HOME"),".crm_help_index") def __init__(self): self.key_pos = {} self.key_list = [] self.no_help_file = False # don't print repeatedly messages self.bad_index = False # don't print repeatedly warnings for bad index def open_file(self,name,mode): try: f = open(name,mode) return f except IOError,msg: common_err("%s open: %s"%(name,msg)) common_err("extensive help system is not available") self.no_help_file = True return None def drop_index(self): common_info("removing index") os.unlink(self.index_file) self.key_pos = {} self.key_list = [] self.bad_index = True def mk_index(self): ''' Prepare an index file, sorted by topic, with seek positions Do we need a hash on content? ''' if self.no_help_file: return False + crm_help_v = os.getenv("CRM_HELP_FILE") + if crm_help_v: + self.help_text_file = crm_help_v help_f = self.open_file(self.help_text_file,"r") if not help_f: return False idx_f = self.open_file(self.index_file,"w") if not idx_f: return False common_info("building help index") key_pos = {} while 1: pos = help_f.tell() s = help_f.readline() if not s: break if s.startswith("[["): r = re.search(r'..([^,]+),', s) if r: key_pos[r.group(1)] = pos help_f.close() l = key_pos.keys() l.sort() for key in l: print >>idx_f, '%s %d' % (key,key_pos[key]) idx_f.close() return True def is_index_old(self): try: t_idx = os.path.getmtime(self.index_file) except: return True try: t_help = os.path.getmtime(self.help_text_file) except: return True return t_help > t_idx def load_index(self): if self.is_index_old(): self.mk_index() self.key_pos = {} idx_f = self.open_file(self.index_file,"r") if not idx_f: return False for s in idx_f: a = s.split() if len(a) != 2: if not self.bad_index: common_err("index file corrupt") idx_f.close() self.drop_index() return self.load_index() # this runs only once return False self.key_pos[a[0]] = long(a[1]) idx_f.close() self.key_list = self.key_pos.keys() self.key_list.sort() return True def __filter(self,s): if '<<' in s: return re.sub(r'<<[^,]+,(.+)>>', r'\1', s) else: return s def __find_key(self,key): low = 0 high = len(self.key_list)-1 while low <= high: mid = (low + high)/2 if self.key_list[mid] > key: high = mid - 1 elif self.key_list[mid] < key: low = mid + 1 else: return mid return -1 def __load_help_one(self,key,skip = 2): longhelp = '' self.help_f.seek(self.key_pos[key]) shorthelp = help_short(self.help_f.readline()) for i in range(skip-1): self.help_f.readline() l = [] for s in self.help_f: if s.startswith("[[") or s.startswith("="): break l.append(self.__filter(s)) if l and l[-1] == '\n': # drop the last line of empty l.pop() if l: longhelp = ''.join(l) if not shorthelp or not longhelp: if not self.bad_index: common_warn("help topic %s not found" % key) self.drop_index() return shorthelp,longhelp def cmdhelp(self,s): if not self.key_pos and not self.load_index(): return None,None if not s in self.key_pos: if not self.bad_index: common_warn("help topic %s not found" % s) self.drop_index() return None,None return self.__load_help_one(s) def __load_level(self,lvl): ''' For the given level, create a help table. ''' if wcache.is_cached("lvl_help_tab_%s" % lvl): return wcache.retrieve("lvl_help_tab_%s" % lvl) if not self.key_pos and not self.load_index(): return None self.help_f = self.open_file(self.help_text_file,"r") if not self.help_f: return None lvl_s = "cmdhelp_%s" % lvl if not lvl_s in self.key_pos: if not self.bad_index: common_warn("help table for level %s not found" % lvl) self.drop_index() return None common_debug("loading help table for level %s" % lvl) help_tab = odict() help_tab["."] = self.__load_help_one(lvl_s) lvl_idx = self.__find_key(lvl_s) lvl_idx += 1 while lvl_idx < len(self.key_list): key = self.key_list[lvl_idx] if not key.startswith(lvl_s): break cmd = key[len(lvl_s)+1:] help_tab[cmd] = self.__load_help_one(key) lvl_idx += 1 self.help_f.close() help_tab["quit"] = ("exit the program", "") help_tab["help"] = ("show help", "") help_tab["end"] = ("go back one level", "") return help_tab def load_level(self,lvl): help_tab = self.__load_level(lvl) if self.bad_index: # try again help_tab = self.__load_level(lvl) return wcache.store("lvl_help_tab_%s" % lvl, help_tab) # from: http://code.activestate.com/recipes/475116/ class TerminalController(object): """ A class that can be used to portably generate formatted output to a terminal. `TerminalController` defines a set of instance variables whose values are initialized to the control sequence necessary to perform a given action. These can be simply included in normal output to the terminal: >>> term = TerminalController() >>> print 'This is '+term.GREEN+'green'+term.NORMAL Alternatively, the `render()` method can used, which replaces '${action}' with the string required to perform 'action': >>> term = TerminalController() >>> print term.render('This is ${GREEN}green${NORMAL}') If the terminal doesn't support a given action, then the value of the corresponding instance variable will be set to ''. As a result, the above code will still work on terminals that do not support color, except that their output will not be colored. Also, this means that you can test whether the terminal supports a given action by simply testing the truth value of the corresponding instance variable: >>> term = TerminalController() >>> if term.CLEAR_SCREEN: ... print 'This terminal supports clearning the screen.' Finally, if the width and height of the terminal are known, then they will be stored in the `COLS` and `LINES` attributes. """ # Cursor movement: BOL = '' #: Move the cursor to the beginning of the line UP = '' #: Move the cursor up one line DOWN = '' #: Move the cursor down one line LEFT = '' #: Move the cursor left one char RIGHT = '' #: Move the cursor right one char # Deletion: CLEAR_SCREEN = '' #: Clear the screen and move to home position CLEAR_EOL = '' #: Clear to the end of the line. CLEAR_BOL = '' #: Clear to the beginning of the line. CLEAR_EOS = '' #: Clear to the end of the screen # Output modes: BOLD = '' #: Turn on bold mode BLINK = '' #: Turn on blink mode DIM = '' #: Turn on half-bright mode REVERSE = '' #: Turn on reverse-video mode NORMAL = '' #: Turn off all modes # Cursor display: HIDE_CURSOR = '' #: Make the cursor invisible SHOW_CURSOR = '' #: Make the cursor visible # Terminal size: COLS = None #: Width of the terminal (None for unknown) LINES = None #: Height of the terminal (None for unknown) # Foreground colors: BLACK = BLUE = GREEN = CYAN = RED = MAGENTA = YELLOW = WHITE = '' # Background colors: BG_BLACK = BG_BLUE = BG_GREEN = BG_CYAN = '' BG_RED = BG_MAGENTA = BG_YELLOW = BG_WHITE = '' _STRING_CAPABILITIES = """ BOL=cr UP=cuu1 DOWN=cud1 LEFT=cub1 RIGHT=cuf1 CLEAR_SCREEN=clear CLEAR_EOL=el CLEAR_BOL=el1 CLEAR_EOS=ed BOLD=bold BLINK=blink DIM=dim REVERSE=rev UNDERLINE=smul NORMAL=sgr0 HIDE_CURSOR=cinvis SHOW_CURSOR=cnorm""".split() _COLORS = """BLACK BLUE GREEN CYAN RED MAGENTA YELLOW WHITE""".split() _ANSICOLORS = "BLACK RED GREEN YELLOW BLUE MAGENTA CYAN WHITE".split() def __init__(self, term_stream=sys.stdout): """ Create a `TerminalController` and initialize its attributes with appropriate values for the current terminal. `term_stream` is the stream that will be used for terminal output; if this stream is not a tty, then the terminal is assumed to be a dumb terminal (i.e., have no capabilities). """ # Curses isn't available on all platforms try: import curses except: common_info("no curses support: you won't see colors") return # If the stream isn't a tty, then assume it has no capabilities. if not term_stream.isatty(): return # Check the terminal type. If we fail, then assume that the # terminal has no capabilities. try: curses.setupterm() except: return # Look up numeric capabilities. self.COLS = curses.tigetnum('cols') self.LINES = curses.tigetnum('lines') # Look up string capabilities. for capability in self._STRING_CAPABILITIES: (attrib, cap_name) = capability.split('=') setattr(self, attrib, self._tigetstr(cap_name) or '') # Colors set_fg = self._tigetstr('setf') if set_fg: for i,color in zip(range(len(self._COLORS)), self._COLORS): setattr(self, color, curses.tparm(set_fg, i) or '') set_fg_ansi = self._tigetstr('setaf') if set_fg_ansi: for i,color in zip(range(len(self._ANSICOLORS)), self._ANSICOLORS): setattr(self, color, curses.tparm(set_fg_ansi, i) or '') set_bg = self._tigetstr('setb') if set_bg: for i,color in zip(range(len(self._COLORS)), self._COLORS): setattr(self, 'BG_'+color, curses.tparm(set_bg, i) or '') set_bg_ansi = self._tigetstr('setab') if set_bg_ansi: for i,color in zip(range(len(self._ANSICOLORS)), self._ANSICOLORS): setattr(self, 'BG_'+color, curses.tparm(set_bg_ansi, i) or '') def _tigetstr(self, cap_name): # String capabilities can include "delays" of the form "$<2>". # For any modern terminal, we should be able to just ignore # these, so strip them out. import curses cap = curses.tigetstr(cap_name) or '' return re.sub(r'\$<\d+>[/*]?', '', cap) def render(self, template): """ Replace each $-substitutions in the given template string with the corresponding terminal control string (if it's defined) or '' (if it's not). """ return re.sub(r'\$\$|\${\w+}', self._render_sub, template) def _render_sub(self, match): s = match.group() if s == '$$': return s else: return getattr(self, s[2:-1]) def is_color(self, s): try: attr = getattr(self, s.upper()) return attr != None except: return False class CliDisplay(object): """ Display output for various syntax elements. """ def __init__(self): self.no_pretty = False def set_no_pretty(self): self.no_pretty = True def reset_no_pretty(self): self.no_pretty = False def colorstring(self, clrnum, s): if self.no_pretty: return s else: return termctrl.render("${%s}%s${NORMAL}" % \ (user_prefs.colorscheme[clrnum].upper(), s)) def keyword(self, kw): s = kw if "uppercase" in user_prefs.output: s = s.upper() if "color" in user_prefs.output: s = self.colorstring(0, s) return s def otherword(self, n, s): if "color" in user_prefs.output: return self.colorstring(n, s) else: return s def id(self, s): return self.otherword(1, s) def attr_name(self, s): return self.otherword(2, s) def attr_value(self, s): return self.otherword(3, s) def rscref(self, s): return self.otherword(4, s) def score(self, s): return self.otherword(5, s) global_aliases = { "quit": ("bye","exit"), "end": ("cd","up"), } def setup_aliases(obj): for cmd in obj.cmd_aliases.keys(): for alias in obj.cmd_aliases[cmd]: if obj.help_table: obj.help_table[alias] = obj.help_table[cmd] obj.cmd_table[alias] = obj.cmd_table[cmd] # # Resource Agents interface (meta-data, parameters, etc) # ocf_root = os.getenv("OCF_ROOT") if not ocf_root: ocf_root = "@OCF_ROOT_DIR@" if not ocf_root: ocf_root = "/usr/lib/ocf" os.putenv("OCF_ROOT",ocf_root) class RaLrmd(object): ''' Getting information from the resource agents. ''' lrmadmin_prog = "lrmadmin" def __init__(self): self.good = self.is_lrmd_accessible() def lrmadmin(self, opts, xml = False): ''' Get information directly from lrmd using lrmadmin. ''' l = stdout2list("%s %s" % (self.lrmadmin_prog,opts)) if l and not xml: l = l[1:] # skip the first line return l def is_lrmd_accessible(self): if not (is_program(self.lrmadmin_prog) and is_process("lrmd")): return False return subprocess.call(\ add_sudo(">/dev/null 2>&1 %s -C" % self.lrmadmin_prog), \ shell=True) == 0 def meta(self, ra_class,ra_type,ra_provider): return self.lrmadmin("-M %s %s %s"%(ra_class,ra_type,ra_provider),True) def providers(self, ra_type,ra_class = "ocf"): 'List of providers for a class:type.' return self.lrmadmin("-P %s %s" % (ra_class,ra_type),True) def classes(self): 'List of providers for a class:type.' return self.lrmadmin("-C") def types(self, ra_class = "ocf", ra_provider = ""): 'List of types for a class.' return self.lrmadmin("-T %s" % ra_class) def os_types_list(path): l = [] for f in glob.glob(path): if os.access(f,os.X_OK) and os.path.isfile(f): a = f.split("/") l.append(a[-1]) return l class RaOS(object): ''' Getting information from the resource agents (direct). ''' def __init__(self): self.good = True def meta(self, ra_class,ra_type,ra_provider): l = [] if ra_class == "ocf": l = stdout2list("%s/resource.d/%s/%s meta-data" % \ (ocf_root,ra_provider,ra_type)) elif ra_class == "stonith": l = stdout2list("stonith -m -t %s" % ra_type) return l def providers(self, ra_type,ra_class = "ocf"): 'List of providers for a class:type.' l = [] if ra_class == "ocf": for s in glob.glob("%s/resource.d/*/%s" % (ocf_root,ra_type)): a = s.split("/") if len(a) == 7: l.append(a[5]) return l def classes(self): 'List of classes.' return "heartbeat lsb ocf stonith".split() def types(self, ra_class = "ocf", ra_provider = ""): 'List of types for a class.' l = [] prov = ra_provider and ra_provider or "*" if ra_class == "ocf": l = os_types_list("%s/resource.d/%s/*" % (ocf_root,prov)) elif ra_class == "lsb": l = os_types_list("/etc/init.d/*") elif ra_class == "stonith": l = stdout2list("stonith -L") l = list(set(l)) l.sort() return l def ra_classes(): ''' List of RA classes. ''' if wcache.is_cached("ra_classes"): return wcache.retrieve("ra_classes") l = ra_if.classes() l.sort() return wcache.store("ra_classes",l) def ra_providers(ra_type,ra_class = "ocf"): 'List of providers for a class:type.' id = "ra_providers-%s-%s" % (ra_class,ra_type) if wcache.is_cached(id): return wcache.retrieve(id) l = ra_if.providers(ra_type,ra_class) l.sort() return wcache.store(id,l) def ra_providers_all(ra_class = "ocf"): ''' List of providers for a class. ''' id = "ra_providers_all-%s" % ra_class if wcache.is_cached(id): return wcache.retrieve(id) dir = ocf_root + "/resource.d" l = [] for s in os.listdir(dir): if os.path.isdir("%s/%s" % (dir,s)): l.append(s) l.sort() return wcache.store(id,l) def ra_types(ra_class = "ocf", ra_provider = ""): ''' List of RA type for a class. ''' if not ra_class: ra_class = "ocf" id = "ra_types-%s-%s" % (ra_class,ra_provider) if wcache.is_cached(id): return wcache.retrieve(id) if ra_provider: list = [] for ra in ra_if.types(ra_class): if ra_provider in ra_providers(ra,ra_class): list.append(ra) else: list = ra_if.types(ra_class) list.sort() return wcache.store(id,list) def prog_meta(s): ''' Do external program metadata. ''' prog = "@CRM_DAEMON_DIR@/%s" % s l = [] if is_program(prog): l = stdout2list("%s metadata" % prog) return l def get_nodes_text(n,tag): try: node = n.getElementsByTagName(tag)[0] for c in node.childNodes: if c.nodeType == c.TEXT_NODE: return c.data.strip() except: return '' def mk_monitor_name(role,depth): depth = depth == "0" and "" or ("_%s" % depth) return role and role != "Started" and \ "monitor_%s%s" % (role,depth) or \ "monitor%s" % depth def monitor_name_node(node): depth = node.getAttribute("depth") or '0' role = node.getAttribute("role") return mk_monitor_name(role,depth) def monitor_name_pl(pl): depth = find_value(pl, "depth") or '0' role = find_value(pl, "role") return mk_monitor_name(role,depth) def crm_msec(t): ''' See lib/common/utils.c:crm_get_msec(). ''' convtab = { 'ms': (1,1), 'msec': (1,1), 'us': (1,1000), 'usec': (1,1000), '': (1000,1), 's': (1000,1), 'sec': (1000,1), 'm': (60*1000,1), 'min': (60*1000,1), 'h': (60*60*1000,1), 'hr': (60*60*1000,1), } if not t: return -1 r = re.match("\s*(\d+)\s*([a-zA-Z]+)?", t) if not r: return -1 if not r.group(2): q = '' else: q = r.group(2).lower() try: mult,div = convtab[q] except: return -1 return (int(r.group(1))*mult)/div def crm_time_cmp(a, b): return crm_msec(a) - crm_msec(b) class RAInfo(object): ''' A resource agent and whatever's useful about it. ''' ra_tab = " " # four horses required_ops = ("start", "stop") skip_ops = ("meta-data", "validate-all") skip_op_attr = ("name", "depth", "role") def __init__(self,ra_class,ra_type,ra_provider = "heartbeat"): self.ra_class = ra_class self.ra_type = ra_type self.ra_provider = ra_provider if not self.ra_provider: self.ra_provider = "heartbeat" self.ra_node = None def ra_string(self): return self.ra_class == "ocf" and \ "%s:%s:%s" % (self.ra_class, self.ra_provider, self.ra_type) or \ "%s:%s" % (self.ra_class, self.ra_type) def error(self, s): common_err("%s: %s" % (self.ra_string(), s)) def warn(self, s): common_warn("%s: %s" % (self.ra_string(), s)) def add_extra_stonith_params(self): if not stonithd_metadata.mk_ra_node(): return try: params_node = self.doc.getElementsByTagName("parameters")[0] except: params_node = self.doc.createElement("parameters") self.ra_node.appendChild(params_node) for n in stonithd_metadata.ra_node.getElementsByTagName("parameter"): params_node.appendChild(self.doc.importNode(n,1)) def mk_ra_node(self): ''' Return the resource_agent node. ''' if self.ra_node: return self.ra_node meta = self.meta() try: self.doc = xml.dom.minidom.parseString('\n'.join(meta)) except: #common_err("could not parse meta-data for (%s,%s,%s)" \ # % (self.ra_class,self.ra_type,self.ra_provider)) self.ra_node = None return None try: self.ra_node = self.doc.getElementsByTagName("resource-agent")[0] except: self.error("meta-data contains no resource-agent element") self.ra_node = None return None if self.ra_class == "stonith": self.add_extra_stonith_params() return self.ra_node def param_type_default(self,n): try: content = n.getElementsByTagName("content")[0] type = content.getAttribute("type") default = content.getAttribute("default") return type,default except: return None,None def params(self): ''' Construct a dict of dicts: parameters are keys and dictionary of attributes/values are values. Cached too. ''' id = "ra_params-%s" % self.ra_string() if wcache.is_cached(id): return wcache.retrieve(id) if not self.mk_ra_node(): return None d = {} for pset in self.ra_node.getElementsByTagName("parameters"): for c in pset.getElementsByTagName("parameter"): name = c.getAttribute("name") if not name: continue required = c.getAttribute("required") unique = c.getAttribute("unique") type,default = self.param_type_default(c) d[name] = { "required": required, "unique": unique, "type": type, "default": default, } return wcache.store(id,d) def actions(self): ''' Construct a dict of dicts: actions are keys and dictionary of attributes/values are values. Cached too. ''' id = "ra_actions-%s" % self.ra_string() if wcache.is_cached(id): return wcache.retrieve(id) if not self.mk_ra_node(): return None d = {} for pset in self.ra_node.getElementsByTagName("actions"): for c in pset.getElementsByTagName("action"): name = c.getAttribute("name") if not name or name in self.skip_ops: continue if name == "monitor": name = monitor_name_node(c) d[name] = {} for a in c.attributes.keys(): if a in self.skip_op_attr: continue v = c.getAttribute(a) if v: d[name][a] = v # add monitor ops without role, if they don't already # exist d2 = {} for op in d.keys(): if re.match("monitor_[^0-9]", op): norole_op = re.sub(r'monitor_[^0-9_]+_(.*)', r'monitor_\1', op) if not norole_op in d: d2[norole_op] = d[op] d.update(d2) return wcache.store(id,d) def reqd_params_list(self): ''' List of required parameters. ''' d = self.params() if not d: return [] return [x for x in d if d[x]["required"] == '1'] def param_default(self,pname): ''' Parameter's default. ''' d = self.params() if not d: return None return d[pname]["default"] def sanity_check_params(self, id, pl): ''' pl is a list of (attribute,value) pairs. - are all required parameters defined - do all parameters exist ''' rc = 0 d = {} for p,v in pl: d[p] = v for p in self.reqd_params_list(): if p not in d: common_err("%s: required parameter %s not defined" % (id,p)) rc |= user_prefs.get_check_rc() for p in d: if p not in self.params(): common_err("%s: parameter %s does not exist" % (id,p)) rc |= user_prefs.get_check_rc() return rc def sanity_check_ops(self, id, ops): ''' ops is a dict, operation names are keys and values are lists of (attribute,value) pairs. - do all operations exist - are timeouts sensible ''' rc = 0 n_ops = {} for op in ops: n_op = op == "monitor" and monitor_name_pl(ops[op]) or op n_ops[n_op] = {} for p,v in ops[op]: if p in self.skip_op_attr: continue n_ops[n_op][p] = v default_timeout = get_default("default-action-timeout") for req_op in self.required_ops: if req_op not in n_ops: n_ops[req_op] = {} for op in n_ops: if op not in self.actions(): common_warn("%s: action %s not advertised in meta-data, it may not be supported by the RA" % (id,op)) rc |= 1 continue try: adv_timeout = self.actions()[op]["timeout"] except: continue for a in n_ops[op]: v = n_ops[op][a] if a == "timeout": if crm_msec(v) < 0: continue if crm_time_cmp(adv_timeout,v) > 0: common_warn("%s: timeout %s for %s is smaller than the advised %s" % \ (id,v,op,adv_timeout)) rc |= 1 return rc def meta(self): ''' RA meta-data as raw xml. ''' id = "ra_meta-%s" % self.ra_string() if wcache.is_cached(id): return wcache.retrieve(id) if self.ra_class in ("pengine","stonithd"): l = prog_meta(self.ra_class) else: l = ra_if.meta(self.ra_class,self.ra_type,self.ra_provider) return wcache.store(id, l) def meta_pretty(self): ''' Print the RA meta-data in a human readable form. ''' if not self.mk_ra_node(): return '' l = [] title = self.meta_title() l.append(title) longdesc = get_nodes_text(self.ra_node,"longdesc") if longdesc: l.append(longdesc) if self.ra_class != "heartbeat": params = self.meta_parameters() if params: l.append(params.rstrip()) actions = self.meta_actions() if actions: l.append(actions) return '\n\n'.join(l) def get_shortdesc(self,n): name = n.getAttribute("name") shortdesc = get_nodes_text(n,"shortdesc") longdesc = get_nodes_text(n,"longdesc") if shortdesc and shortdesc not in (name,longdesc,self.ra_type): return shortdesc return '' def meta_title(self): s = self.ra_string() shortdesc = self.get_shortdesc(self.ra_node) if shortdesc: s = "%s (%s)" % (shortdesc,s) return s def meta_param_head(self,n): name = n.getAttribute("name") if not name: return None s = name if n.getAttribute("required") == "1": s = s + "*" type,default = self.param_type_default(n) if type and default: s = "%s (%s, [%s])" % (s,type,default) elif type: s = "%s (%s)" % (s,type) shortdesc = self.get_shortdesc(n) s = "%s: %s" % (s,shortdesc) return s def format_parameter(self,n): l = [] head = self.meta_param_head(n) if not head: self.error("no name attribute for parameter") return "" l.append(head) longdesc = get_nodes_text(n,"longdesc") if longdesc: longdesc = self.ra_tab + longdesc.replace("\n","\n"+self.ra_tab) + '\n' l.append(longdesc) return '\n'.join(l) def meta_parameter(self,param): if not self.mk_ra_node(): return '' l = [] for pset in self.ra_node.getElementsByTagName("parameters"): for c in pset.getElementsByTagName("parameter"): if c.getAttribute("name") == param: return self.format_parameter(c) def meta_parameters(self): if not self.mk_ra_node(): return '' l = [] for pset in self.ra_node.getElementsByTagName("parameters"): for c in pset.getElementsByTagName("parameter"): s = self.format_parameter(c) if s: l.append(s) if l: return "Parameters (* denotes required, [] the default):\n\n" + '\n'.join(l) def meta_action_head(self,n): name = n.getAttribute("name") if not name: return '' if name in self.skip_ops: return '' if name == "monitor": name = monitor_name_node(n) s = "%-13s" % name for a in n.attributes.keys(): if a in self.skip_op_attr: continue v = n.getAttribute(a) if v: s = "%s %s=%s" % (s,a,v) return s def meta_actions(self): l = [] for aset in self.ra_node.getElementsByTagName("actions"): for c in aset.getElementsByTagName("action"): s = self.meta_action_head(c) if s: l.append(self.ra_tab + s) if l: return "Operations' defaults (advisory minimum):\n\n" + '\n'.join(l) def cmd_end(cmd,dir = ".."): "Go up one level." levels.droplevel() def cmd_exit(cmd): "Exit the crm program" cmd_end(cmd) if interactive: print "bye" try: readline.write_history_file(hist_file) except: pass for f in tmpfiles: os.unlink(f) sys.exit() # # help or make users feel less lonely # def add_shorthelp(topic,shorthelp,topic_help): ''' Join topics ("%s,%s") if they share the same short description. ''' for i in range(len(topic_help)): if topic_help[i][1] == shorthelp: topic_help[i][0] = "%s,%s" % (topic_help[i][0], topic) return topic_help.append([topic, shorthelp]) def dump_short_help(help_tab): topic_help = [] for topic in help_tab: if topic == '.': continue # with odict, for whatever reason, python parses differently: # help_tab["..."] = ("...","...") and # help_tab["..."] = ("...",""" # ...""") # a parser bug? if type(help_tab[topic][0]) == type(()): shorthelp = help_tab[topic][0][0] else: shorthelp = help_tab[topic][0] add_shorthelp(topic,shorthelp,topic_help) for t,d in topic_help: print "\t%-16s %s" % (t,d) def overview(help_tab): print "" print help_tab['.'][1] print "" print "Available commands:" print "" dump_short_help(help_tab) print "" def topic_help(help_tab,topic): if topic not in help_tab: print "There is no help for topic %s" % topic return if type(help_tab[topic][0]) == type(()): shorthelp = help_tab[topic][0][0] longhelp = help_tab[topic][0][1] else: shorthelp = help_tab[topic][0] longhelp = help_tab[topic][1] if longhelp: page_string(longhelp) else: print shorthelp def cmd_help(help_tab,topic = ''): "help!" # help_tab is an odict (ordered dictionary): # help_tab[topic] = (short_help,long_help) # topic '.' is a special entry for the top level if not help_tab: common_info("sorry, help not available") return if not topic: overview(help_tab) else: topic_help(help_tab,topic) class UserInterface(object): ''' Stuff common to all user interface classes. ''' def __init__(self): self.cmd_table = odict() self.cmd_table["help"] = (self.help,(0,1),0) self.cmd_table["quit"] = (self.exit,(0,0),0) self.cmd_table["end"] = (self.end,(0,1),0) self.cmd_aliases = global_aliases.copy() def end_game(self, no_questions_asked = False): pass def help(self,cmd,topic = ''): "usage: help []" cmd_help(self.help_table,topic) def end(self,cmd,dir = ".."): "usage: end" self.end_game() cmd_end(cmd,dir) def exit(self,cmd): "usage: exit" self.end_game() cmd_exit(cmd) def add_sudo(cmd): if user_prefs.crm_user: return "sudo -E -u %s %s"%(user_prefs.crm_user,cmd) return cmd def pipe_string(cmd,s): rc = -1 # command failed cmd = add_sudo(cmd) p = subprocess.Popen(cmd, shell=True, stdin=subprocess.PIPE) try: p.communicate(s) p.wait() rc = p.returncode except IOError, msg: common_err(msg) return rc def cibdump2doc(section = None): doc = None if section: cmd = "%s -o %s" % (cib_dump,section) else: cmd = cib_dump cmd = add_sudo(cmd) p = subprocess.Popen(cmd, shell=True, stdout=subprocess.PIPE) try: doc = xmlparse(p.stdout) p.wait() except IOError, msg: common_err(msg) return None return doc def file2doc(s): try: f = open(s,'r') except IOError, msg: common_err(msg) return None doc = xmlparse(f) f.close() return doc def shadow2doc(name): return file2doc(shadowfile(name)) def str2tmp(s): ''' Write the given string to a temporary file. Return the name of the file. ''' fd,tmp = mkstemp() try: f = os.fdopen(fd,"w") except IOError, msg: common_err(msg) return f.write(s) f.close() return tmp def is_filename_sane(name): if re.search("['`/#*?$\[\]]",name): common_err("%s: bad name"%name) return False return True def is_name_sane(name): if re.search("[']",name): common_err("%s: bad name"%name) return False return True def is_value_sane(name): if re.search("[']",name): common_err("%s: bad name"%name) return False return True def ext_cmd(cmd): if regression_tests: print ".EXT", cmd return subprocess.call(add_sudo(cmd), shell=True) def get_stdout(cmd, stderr_on = True): ''' Run a cmd, return stdin output. stderr_on controls whether to show output which comes on stderr. ''' if stderr_on: stderr = None else: stderr = subprocess.PIPE proc = subprocess.Popen(cmd, shell = True, \ stdout = subprocess.PIPE, stderr = stderr) outp = proc.communicate()[0] proc.wait() outp = outp.strip() return outp def stdout2list(cmd, stderr_on = True): ''' Run a cmd, fetch output, return it as a list of lines. stderr_on controls whether to show output which comes on stderr. ''' s = get_stdout(add_sudo(cmd), stderr_on) return s.split('\n') def find_program(envvar,*args): if envvar and os.getenv(envvar): return os.getenv(envvar) for prog in args: if is_program(prog): return prog def is_id_valid(id): """ Verify that the id follows the definition: http://www.w3.org/TR/1999/REC-xml-names-19990114/#ns-qualnames """ if not id: return False id_re = "^[A-Za-z_][\w._-]*$" return re.match(id_re,id) def check_filename(fname): """ Verify that the string is a filename. """ fname_re = "^[^/]+$" return re.match(fname_re,id) class UserPrefs(object): ''' Keep user preferences here. ''' dflt_colorscheme = "yellow,normal,cyan,red,green,magenta".split(',') skill_levels = {"operator":0, "administrator":1, "expert":2} output_types = ("plain", "color", "uppercase") check_frequencies = ("always", "on-verify", "never") check_modes = ("strict", "relaxed") def __init__(self): self.skill_level = 2 #TODO: set back to 0? self.editor = find_program("EDITOR","vim","vi","emacs","nano") self.pager = find_program("PAGER","less","more","pg") self.dotty = find_program("","dotty") if not self.editor: missing_prog_warn("editor") if not self.pager: missing_prog_warn("pager") self.crm_user = "" self.xmlindent = " " # two spaces # keywords,ids,attribute names,values self.colorscheme = self.dflt_colorscheme # plain or color self.output = ['color',] # the semantic checks preferences self.check_frequency = "always" self.check_mode = "strict" self.debug = False self.force = False def check_skill_level(self,n): return self.skill_level >= n def set_skill_level(self,skill_level): if skill_level in self.skill_levels: self.skill_level = self.skill_levels[skill_level] else: common_err("no %s skill level"%skill_level) return False def get_skill_level(self): for s in self.skill_levels: if self.skill_level == self.skill_levels[s]: return s def set_editor(self,prog): if is_program(prog): self.editor = prog else: common_err("program %s does not exist"% prog) return False def set_pager(self,prog): if is_program(prog): self.pager = prog else: common_err("program %s does not exist"% prog) return False def set_crm_user(self,user = ''): self.crm_user = user def set_output(self,otypes): l = otypes.split(',') for otype in l: if not otype in self.output_types: common_err("no %s output type" % otype) return False self.output = l def set_colors(self,scheme): colors = scheme.split(',') if len(colors) != 6: common_err("bad color scheme: %s"%scheme) colors = UserPrefs.dflt_colorscheme rc = True for c in colors: if not termctrl.is_color(c): common_err("%s is not a recognized color" % c) rc = False if rc: self.colorscheme = colors else: self.output.remove("color") return rc def is_check_always(self): ''' Even though the frequency may be set to always, it doesn't make sense to do that with non-interactive sessions. ''' return interactive and self.check_frequency == "always" def get_check_rc(self): ''' If the check mode is set to strict, then on errors we return 2 which is the code for error. Otherwise, we pretend that errors are warnings. ''' return self.check_mode == "strict" and 2 or 1 def set_check_freq(self,frequency): if frequency not in self.check_frequencies: common_err("no %s check frequency"%frequency) return False self.check_frequency = frequency def set_check_mode(self,mode): if mode not in self.check_modes: common_err("no %s check mode"%mode) return False self.check_mode = mode def set_debug(self): self.debug = True def get_debug(self): return self.debug def set_force(self): self.force = True def get_force(self): return self.force def write_rc(self,f): print >>f, '%s "%s"' % ("editor",self.editor) print >>f, '%s "%s"' % ("pager",self.pager) print >>f, '%s "%s"' % ("user",self.crm_user) print >>f, '%s "%s"' % ("skill-level",self.get_skill_level()) print >>f, '%s "%s"' % ("output", ','.join(self.output)) print >>f, '%s "%s"' % ("colorscheme", ','.join(self.colorscheme)) print >>f, '%s "%s"' % ("check-frequency",self.check_frequency) print >>f, '%s "%s"' % ("check-mode",self.check_mode) def save_options(self): try: f = open(rc_file,"w") - except os.error,msg: + except IOError,msg: common_err("open: %s"%msg) return print >>f, 'options' self.write_rc(f) print >>f, 'end' f.close() class CliOptions(UserInterface): ''' Manage user preferences ''' def __init__(self): UserInterface.__init__(self) self.help_table = help_sys.load_level("options") self.cmd_table["skill-level"] = (self.set_skill_level,(1,1),0,(skills_list,)) self.cmd_table["editor"] = (self.set_editor,(1,1),0) self.cmd_table["pager"] = (self.set_pager,(1,1),0) self.cmd_table["user"] = (self.set_crm_user,(0,1),0) self.cmd_table["output"] = (self.set_output,(1,1),0) self.cmd_table["colorscheme"] = (self.set_colors,(1,1),0) self.cmd_table["check-frequency"] = (self.set_check_frequency,(1,1),0) self.cmd_table["check-mode"] = (self.set_check_mode,(1,1),0) self.cmd_table["save"] = (self.save_options,(0,0),0) self.cmd_table["show"] = (self.show_options,(0,0),0) setup_aliases(self) def set_skill_level(self,cmd,skill_level): """usage: skill-level level: operator | administrator | expert""" return user_prefs.set_skill_level(skill_level) def set_editor(self,cmd,prog): "usage: editor " return user_prefs.set_editor(prog) def set_pager(self,cmd,prog): "usage: pager " return user_prefs.set_pager(prog) def set_crm_user(self,cmd,user = ''): "usage: user []" return user_prefs.set_crm_user(user) def set_output(self,cmd,otypes): "usage: output " return user_prefs.set_output(otypes) def set_colors(self,cmd,scheme): "usage: colorscheme " return user_prefs.set_colors(scheme) def set_check_frequency(self,cmd,freq): "usage: check-frequence " return user_prefs.set_check_freq(freq) def set_check_mode(self,cmd,mode): "usage: check-mode " return user_prefs.set_check_mode(mode) def show_options(self,cmd): "usage: show" return user_prefs.write_rc(sys.stdout) def save_options(self,cmd): "usage: save" return user_prefs.save_options() def end_game(self, no_questions_asked = False): if no_questions_asked and not interactive: self.save_options("save") cib_dump = "cibadmin -Ql" cib_piped = "cibadmin -p" cib_upgrade = "cibadmin --upgrade --force" cib_verify = "crm_verify -V -p" class WCache(object): "Cache stuff. A naive implementation." def __init__(self): self.lists = {} self.stamp = time.time() self.max_cache_age = 600 # seconds def is_cached(self,name): if time.time() - self.stamp > self.max_cache_age: self.stamp = time.time() self.clear() return name in self.lists def store(self,name,lst): self.lists[name] = lst return lst def retrieve(self,name): if self.is_cached(name): return self.lists[name] else: return None def clear(self): self.lists = {} def listshadows(): return stdout2list("ls @CRM_CONFIG_DIR@ | fgrep shadow. | sed 's/^shadow\.//'") def shadowfile(name): return "@CRM_CONFIG_DIR@/shadow.%s" % name class CibShadow(UserInterface): ''' CIB shadow management class ''' envvar = "CIB_shadow" extcmd = ">/dev/null &1" % self.extcmd) except os.error: no_prog_err(self.extcmd) return False return True def new(self,cmd,name,*args): "usage: new [withstatus] [force]" if not is_filename_sane(name): return False new_cmd = "%s -c '%s'" % (self.extcmd,name) for par in args: if not par in ("force","--force","withstatus"): syntax_err((cmd,name,par), context = 'new') return False if user_prefs.get_force() or "force" in args or "--force" in args: new_cmd = "%s --force" % new_cmd if ext_cmd(new_cmd) == 0: common_info("%s shadow CIB created"%name) self.use("use",name) if "withstatus" in args: cib_status.load("shadow:%s" % name) def delete(self,cmd,name): "usage: delete " if not is_filename_sane(name): return False if cib_in_use == name: common_err("%s shadow CIB is in use"%name) return False if ext_cmd("%s -D '%s' --force" % (self.extcmd,name)) == 0: common_info("%s shadow CIB deleted"%name) else: common_err("failed to delete %s shadow CIB"%name) return False def reset(self,cmd,name): "usage: reset " if not is_filename_sane(name): return False if ext_cmd("%s -r '%s'" % (self.extcmd,name)) == 0: common_info("copied live CIB to %s"%name) else: common_err("failed to copy live CIB to %s"%name) return False def commit(self,cmd,name): "usage: commit " if not is_filename_sane(name): return False if ext_cmd("%s -C '%s' --force" % (self.extcmd,name)) == 0: common_info("commited '%s' shadow CIB to the cluster"%name) wcache.clear() else: common_err("failed to commit the %s shadow CIB"%name) return False def diff(self,cmd): "usage: diff" s = get_stdout(add_sudo("%s -d" % self.extcmd_stdout)) page_string(s) def list(self,cmd): "usage: list" if regression_tests: for t in listshadows(): print t else: multicolumn(listshadows()) def _use(self,name,withstatus): # Choose a shadow cib for further changes. If the name # provided is empty, then choose the live (cluster) cib. # Don't allow ' in shadow names global cib_in_use if not name or name == "live": os.unsetenv(self.envvar) cib_in_use = "" if withstatus: cib_status.load("live") else: os.putenv(self.envvar,name) cib_in_use = name if withstatus: cib_status.load("shadow:%s" % name) def use(self,cmd,name = '', withstatus = ''): "usage: use [] [withstatus]" # check the name argument if name and not is_filename_sane(name): return False if name and name != "live": if not os.access(shadowfile(name),os.F_OK): common_err("%s: no such shadow CIB"%name) return False if withstatus and withstatus != "withstatus": syntax_err((cmd,withstatus), context = 'use') return False # If invoked from configure # take special precautions try: prev_level = levels.previous().myname() except: prev_level = '' if prev_level != "cibconfig": self._use(name,withstatus) return True if not cib_factory.has_cib_changed(): self._use(name,withstatus) # new CIB: refresh the CIB factory cib_factory.refresh() return True saved_cib = cib_in_use self._use(name,'') # don't load the status yet if not cib_factory.is_current_cib_equal(silent = True): # user made changes and now wants to switch to a # different and unequal CIB; we refuse to cooperate common_err("the requested CIB is different from the current one") if user_prefs.get_force(): common_info("CIB overwrite forced") elif not ask("All changes will be dropped. Do you want to proceed?"): self._use(saved_cib,'') # revert to the previous CIB return False self._use(name,withstatus) # now load the status too return True def get_var(l,key): for s in l: a = s.split() if len(a) == 2 and a[0] == key: return a[1] return '' def chk_var(l,key): for s in l: a = s.split() if len(a) == 2 and a[0] == key and a[1]: return True return False def chk_key(l,key): for s in l: a = s.split() if len(a) >= 1 and a[0] == key: return True return False def validate_template(l): 'Test for required stuff in a template.' if not chk_var(l,'%name'): common_err("invalid template: missing '%name'") return False if not chk_key(l,'%generate'): common_err("invalid template: missing '%generate'") return False g = l.index('%generate') if not (chk_key(l[0:g],'%required') or chk_key(l[0:g],'%optional')): common_err("invalid template: missing '%required' or '%optional'") return False return True def fix_tmpl_refs(l,id,pfx): for i in range(len(l)): l[i] = l[i].replace(id,pfx) def fix_tmpl_refs_re(l,regex,repl): for i in range(len(l)): l[i] = re.sub(regex,repl,l[i]) class LoadTemplate(object): ''' Load a template and its dependencies, generate a configuration file which should be relatively easy and straightforward to parse. ''' edit_instructions = '''# Edit instructions: # # Add content only at the end of lines starting with '%%'. # Only add content, don't remove or replace anything. # The parameters following '%required' are not optional, # unlike those following '%optional'. # You may also add comments for future reference.''' no_more_edit = '''# Don't edit anything below this line.''' def __init__(self,name): self.name = name self.all_pre_gen = [] self.all_post_gen = [] self.all_pfx = [] def new_pfx(self,name): i = 1 pfx = name while pfx in self.all_pfx: pfx = "%s_%d" % (name,i) i += 1 self.all_pfx.append(pfx) return pfx def generate(self): return '\n'.join([ \ "# Configuration: %s" % self.name, \ '', \ self.edit_instructions, \ '', \ '\n'.join(self.all_pre_gen), \ self.no_more_edit, \ '', \ '%generate', \ '\n'.join(self.all_post_gen)]) def write_config(self,name): try: f = open("%s/%s" % (Template.conf_dir, name),"w") - except os.error,msg: + except IOError,msg: common_err("open: %s"%msg) return False print >>f, self.generate() f.close() return True def load_template(self,tmpl): try: f = open("%s/%s" % (Template.tmpl_dir, tmpl)) - except os.error,msg: + except IOError,msg: common_err("open: %s"%msg) return '' l = (''.join(f)).split('\n') if not validate_template(l): return '' common_info("pulling in template %s" % tmpl) g = l.index('%generate') pre_gen = l[0:g] post_gen = l[g+1:] name = get_var(pre_gen,'%name') for s in l[0:g]: if s.startswith('%depends_on'): a = s.split() if len(a) != 2: common_warn("%s: wrong usage" % s) continue tmpl_id = a[1] tmpl_pfx = self.load_template(a[1]) if tmpl_pfx: fix_tmpl_refs(post_gen,'%'+tmpl_id,'%'+tmpl_pfx) pfx = self.new_pfx(name) fix_tmpl_refs(post_gen, '%_:', '%'+pfx+':') # replace remaining %_, it may be useful at times fix_tmpl_refs(post_gen, '%_', pfx) v_idx = pre_gen.index('%required') or pre_gen.index('%optional') pre_gen.insert(v_idx,'%pfx ' + pfx) self.all_pre_gen += pre_gen self.all_post_gen += post_gen return pfx def post_process(self, params): pfx_re = '(%s)' % '|'.join(self.all_pfx) for n in params: fix_tmpl_refs(self.all_pre_gen, '%% '+n, "%% "+n+" "+params[n]) fix_tmpl_refs_re(self.all_post_gen, \ '%'+pfx_re+'([^:]|$)', r'\1\2') # process %if ... [%else] ... %fi rmidx_l = [] if_seq = False for i in range(len(self.all_post_gen)): s = self.all_post_gen[i] if if_seq: a = s.split() if len(a) >= 1 and a[0] == '%fi': if_seq = False rmidx_l.append(i) elif len(a) >= 1 and a[0] == '%else': outcome = not outcome rmidx_l.append(i) else: if not outcome: rmidx_l.append(i) continue if not s: continue a = s.split() if len(a) == 2 and a[0] == '%if': outcome = not a[1].startswith('%') # not replaced -> false if_seq = True rmidx_l.append(i) rmidx_l.reverse() for i in rmidx_l: del self.all_post_gen[i] def listtemplates(): l = [] for f in os.listdir(Template.tmpl_dir): if os.path.isfile("%s/%s" % (Template.tmpl_dir,f)): l.append(f) return l def listconfigs(): l = [] for f in os.listdir(Template.conf_dir): if os.path.isfile("%s/%s" % (Template.conf_dir,f)): l.append(f) return l def check_transition(inp,state,possible_l): if not state in possible_l: common_err("input (%s) in wrong state %s" % (inp,state)) return False return True class Template(UserInterface): ''' Configuration templates. ''' conf_dir = "%s/%s" % (os.getenv("HOME"),".crmconf") tmpl_dir = "@datadir@/@PACKAGE@/templates" def __init__(self): UserInterface.__init__(self) self.help_table = help_sys.load_level("template") self.cmd_table["new"] = (self.new,(2,),1,(null_list,templates_list,loop)) self.cmd_table["load"] = (self.load,(0,1),1,(config_list,)) self.cmd_table["edit"] = (self.edit,(0,1),1,(config_list,)) self.cmd_table["delete"] = (self.delete,(1,2),1,(config_list,)) self.cmd_table["show"] = (self.show,(0,1),0,(config_list,)) self.cmd_table["apply"] = (self.apply,(0,2),1,(config_list_method,config_list)) self.cmd_table["list"] = (self.list,(0,1),0) setup_aliases(self) self.init_dir() self.curr_conf = '' def init_dir(self): '''Create the conf directory, link to templates''' if not os.path.isdir(self.conf_dir): try: os.makedirs(self.conf_dir) except os.error,msg: common_err("makedirs: %s"%msg) return def get_depends(self,tmpl): '''return a list of required templates''' # Not used. May need it later. try: tf = open("%s/%s" % (self.tmpl_dir, tmpl),"r") - except os.error,msg: + except IOError,msg: common_err("open: %s"%msg) return l = [] for s in tf: a = s.split() if len(a) >= 2 and a[0] == '%depends_on': l += a[1:] tf.close() return l def replace_params(self,s,user_data): change = False for i in range(len(s)): word = s[i] for p in user_data: # is parameter in the word? pos = word.find('%' + p) if pos < 0: continue endpos = pos + len('%' + p) # and it isn't part of another word? if re.match("[A-Za-z0-9]", word[endpos:endpos+1]): continue # if the value contains a space or # it is a value of an attribute # put quotes around it if user_data[p].find(' ') >= 0 or word[pos-1:pos] == '=': v = '"' + user_data[p] + '"' else: v = user_data[p] word = word.replace('%' + p, v) change = True # we did replace something if change: s[i] = word if 'opt' in s: if not change: s = [] else: s.remove('opt') return s def generate(self,l,user_data): '''replace parameters (user_data) and generate output ''' l2 = [] for piece in l: piece2 = [] for s in piece: s = self.replace_params(s,user_data) if s: piece2.append(' '.join(s)) if piece2: l2.append(' \\\n\t'.join(piece2)) return '\n'.join(l2) def process(self,config = ''): '''Create a cli configuration from the current config''' try: f = open("%s/%s" % (self.conf_dir, config or self.curr_conf),'r') - except os.error,msg: + except IOError,msg: common_err("open: %s"%msg) return '' l = [] piece = [] user_data = {} # states START = 0; PFX = 1; DATA = 2; GENERATE = 3 state = START global lineno save_lineno = lineno lineno = 0 rc = True for inp in f: lineno += 1 if inp.startswith('#'): continue if type(inp) == type(u''): inp = inp.encode('ascii') inp = inp.strip() try: s = shlex.split(inp) except ValueError, msg: common_err(msg) continue while '\n' in s: s.remove('\n') if not s: if state == GENERATE and piece: l.append(piece) piece = [] elif s[0] in ("%name","%depends_on","%suggests"): continue elif s[0] == "%pfx": if check_transition(inp,state,(START,DATA)) and len(s) == 2: pfx = s[1] state = PFX elif s[0] == "%required": if check_transition(inp,state,(PFX,)): state = DATA data_reqd = True elif s[0] == "%optional": if check_transition(inp,state,(PFX,DATA)): state = DATA data_reqd = False elif s[0] == "%%": if state != DATA: common_warn("user data in wrong state %s" % state) if len(s) < 2: common_warn("parameter name missing") elif len(s) == 2: if data_reqd: common_err("required parameter %s not set" % s[1]) rc = False elif len(s) == 3: user_data["%s:%s" % (pfx,s[1])] = s[2] else: common_err("%s: syntax error" % inp) elif s[0] == "%generate": if check_transition(inp,state,(DATA,)): state = GENERATE piece = [] elif state == GENERATE: if s: piece.append(s) else: common_err("<%s> unexpected" % inp) if piece: l.append(piece) lineno = save_lineno f.close() if not rc: return '' return self.generate(l,user_data) def new(self,cmd,name,*args): "usage: new